If I declare a property strong, like so:
@property (strong, nonatomic) UIView *iVar;
When I\'m setting it, does it matter if I do
From a memory management perspective, using ivar = ...
or self.property = ...
(note: there's no such thing as self.ivar
) are the same. However, using ivar = ...
doesn't invoke the setter while self.property = ...
does. This has 3 important ramifications, in no particular order:
nonatomic
, then access to the underlying ivar will not take the lock and you will be breaking the atomicity implications.As for only declaring the ivar, it has the same memory management semantics as declaring a local variable. This is documented in section 4.4 of the Objective-C Automatic Reference Counting document, but basically, if it's an object, it will be inferred to be __strong
.