Reputation: 24771
If assign
is a setter, but a property is readonly
, then it will not be doing any setting, so why use assign
?
I am getting this from the Apple docs on class extensions. In this page, I get why you'd want a public readonly property, then make it privately readwrite, but then why not omit the assign
from the public @interface
and just include it in the class extension only?
Upvotes: 1
Views: 138
Reputation: 16725
If you declare a @property
multiple times (typically because you declare a public readonly
property in the header file, and a readwrite
property in an anonymous category in your .m), the memory management schemes have to match.
So if you have this in your .m:
@property (assign, readwrite) NSObject *foo;
Then you need this in your header, and the assign
is mandatory:
@property (assign, readonly) NSObject *foo;
Upvotes: 2
Reputation: 8147
If you leave just (nonatomic)
, the compiler will automatically set the second parameter to assign
.
Upvotes: 0