It is strange that in Big Nerd Ranch iOS 5 book (p.73) and Programming iOS 5 book (O'Reilly, p.314) (updadte: even Kochan's Objective-C book Fourth edition), in the context of ARC, they say the default for properties attribute is assign
... But Apple's documentation says the default is strong
.
I also tried a simple program where if I don't specify strong
, the program works ok, and if I specify strong
, it works the same, and when assign
is used instead, the compiler shows a warning, so it seems the default is indeed strong
.
So if most of the time, we want
@property (nonatomic, readwrite, strong) NSMutableArray *foo;
then we can just write
@property (nonatomic) NSMutableArray *foo;
as the other two (readwrite
and strong
) are the default?
assign
in ARC. It is about the object will be released sooner than usually expected – Fructiferousassign
is the same asunsafe_unretained
under ARC. In other words, the behavior is the same as with assign under MRC. – Salmi