[Solved] UIImageView Recognizer

I would add a gestureRecognizer to each imageView. The function called by the gestureRecognizer would then change the image on the “big picker view”. There is no built-in way to get the image name that the user chose. If you really needed this, then you could sublcass UIImageView and add a fileName property. @IBOutlet var … Read more

[Solved] Showing array content on a button, using a label

So just to get this straight. Each time you press the button you want to display the next element in the array through the label. Okay, that should be fairly simple. Something like below will do that for you. var primeString = [“60″,”52″,”81″,”61″,”85”] var currentElement = 0 @IBOutlet var PrimeLabel: UILabel! @IBAction func NewAction(sender: AnyObject) … Read more

[Solved] Type Properties In Swift [duplicate]

You can define properties of a type to either be associated with the type itself (these are called Type properties), but you can also define properties to be associated with a specific instance of that type. Type properties are usually used when you want to define something that is the same for each instance of … Read more

[Solved] NSDictionary with swift [closed]

for group in data { let userNames = group.1.reduce(“username “, combine: { (current, userInfo) -> String in return “\(current), \(userInfo[“username”]!)” }) print(“\(group.0) \(userNames)”) } 2 solved NSDictionary with swift [closed]

[Solved] Is it complusory to use “in” keyword in closure? If no then what is the syntax wise difference between closure and computed property in swift?

greet is a closure. A computed property is var greet : Int { return 4+3 } greet // without parentheses And “in” in closure is also not compulsory if a parameter is passed (by the way the return keyword is not compulsory) var greet = { x in 4+x } greet(4) unless you use the … Read more

[Solved] how to filter current array using another array

You can filter an array of Hotels to only keep hotels that contain a RoomPrice whose roomType property is present in an array of RoomFilter using two nested contains(where:) calls inside your filter, one searching Hotel.prices and the other one searching roomFilters to see if there is at least a single common element between the … Read more

[Solved] How to use advance function in swift with three parameters?

That function increments the start index by n positions, but not beyond the end index. Example: You want to truncate strings to a given maximal length: func truncate(string : String, length : Int) -> String { let index = advance(string.startIndex, length, string.endIndex) return string.substringToIndex(index) } println(truncate(“fooBar”, 3)) // foo println(truncate(“fo”, 3)) // fo In the … Read more

[Solved] set UIslider thumb image in swift

If you want to clip the top part of the thumbImage, you should use: public func thumbRectForBounds(bounds: CGRect, trackRect rect: CGRect, value: Float) -> CGRect So add this to your code: durationSlider.thumbRectForBounds(…) And set the CGRect of the thumbRect to have the value of durationSlider.frame.origin.y as its own origin.y. Here’s another temporary solution, I’ll get … Read more