I am looking for a general access solution:
- Obj-C named getters properties and named property definition tools from Swift
- Corresponds to Objective-C
@protocolwith readonlyproperties
Similar to Creating an Objective-C equivalent Getter and Setter in Swift , which is closed but does not give a satisfactory answer.
Objective-C Swift Example:
I have an Objective-C protocol defined with two problematic properties, one with a custom getter isEnabled, and the other with a private installer exists.
@protocol SomeProtocol <NSObject>
@property (nonatomic, assign, getter = isEnabled) BOOL enabled;
@property (nonatomic, readonly) BOOL exists;
@end
How can I access these Objective-C properties from Swift?
This does not work:
func isEnabled() -> Bool { return self.enabled }
and does not:
var isEnabled:Bool {
get { }
set { }
}