Reputation: 3561
In the objective-c header we have a property like so:
@property (nonatomic,assign,getter=isMyThingEnabled) BOOL enableMyThing;
In swift any attempt to access this property like so generates an error that the property is not found:
myClassInstance.isMyThingEnabled
So how do I access the property isMyThingEnabled in swift?
Upvotes: 2
Views: 564
Reputation:
You can define a getter to customize the behavior and the returned value of this property but you should use the property name, not the getter name, and the getter shall be invoked automatically
Upvotes: 0
Reputation: 539815
Even if you defined a custom name for the getter method in Objective-C, the access from Swift is still done using the property name, so this works:
let enabled = myClassInstance.enableMyThing
Upvotes: 2