I want to check if the elements of an Array are a subclass of UILabel in Swift:
import UIKit
var u1 = UILabel()
u1.text=\"hello\"
var u2 = UIView(frame: CGR
In Swift you should do the is
keyword if you are wondering about the according class. In the filter
-closure you can use $0
to specify the first parameter.
var (a,b,c,d) = ("String", 42, 10.0, "secondString")
let myArray: Array = [a,b,c,d]
var onlyStrings = myArray.filter({ return $0 is String })
onlyStrings // ["String", "secondString"]