I noticed some code example in Apple’s documentation shows the following style when declaring the property:
@property (nonatomic, getter=isActivated) BOOL activated;
I understand it allows you to specify a certain name for your getter method. I’d like to know what is the reason and advantage to use this style.
Will I be able to use the dot notation to get the value (e.g. BOOL aBool = someObject.isActivated)? Or should I use
[someObject isActivated];
to access the property? Thanks!
No, the
getterkeyword only changes the method name. The idea is that you’ll access the property just like a variable:But when you’re sending a message to the object, it’s readable code:
if ([self isActivated]) { ... }.