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?
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?
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
Adapted from Apple's ListerKit sample code:
Update for Swift 3:
It can be written like this
Bonus tip: Maybe you would like to have a type safe getter to the layer? Then you can write
In iOS 10, this is a calculated property instead of a method: