In Objective-C we use to do it like this
+ (Class)layerClass
{
return [CAEAGLLayer class];
}
Obviously this won't work:
CAEAGLLayer.class()
Because class
is a keyword in Swift. How do you do it in Swift?
Adapted from Apple's ListerKit sample code:
override class func layerClass() -> AnyClass {
return CAEAGLLayer.self
}
Update for Swift 3:
override class var layerClass: AnyClass {
get {
return CAGradientLayer.self
}
}
In iOS 10, this is a calculated property instead of a method:
override class var layerClass: AnyClass {
get {
return CAEAGLLayer.self
}
}
Swift does introspection much differently than Objective-C. You may want to take a look at the docs about Metatypes.
For your case I'd try: CAEAGLLayer.self
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With