As a side note, overriding the ivar type in the @property
statement @property
also be useful if you want to declare a property as a type immutable for ivar, for example:
@interface MyClass : NSObject { NSMutableArray *myArray; } @property (retain) NSArray *myArray;
In this case, ivar is actually stored as NSMutableArray
, so it can be changed during the life cycle of the object.
However, this is an internal detail, and if you do not want to βadvertiseβ as mutable (mutable), you can make the property type an immutable type β in this case, NSArray
.
Although this will not actually stop the other code using the returned array as mutable, this is a good convention and notifies the other code that it should not be treated like that.
source share