If I have a property like this:
@property(strong, readwrite, nonatomic) NSDate* aProperty;
and I want to pass the reference into another method, are these correct:
if([AnotherClass aMethod:&(self.aProperty)]) { ...
if([AnotherClass aMethod:&self.aProperty]) { ...
Considering your example:
This obviously won’t work because the dot notation is, effectively, using the getter accessor method. It’s equivalent to:
You can easily imagine why the compiler is a little confused about this notation. The logical alternative would be to reference the ivar. Thus, (assuming you’re using the underscore convention for the property’s ivar) it might look like:
But that has all sorts of issues (bypassing setter, having issues about
aMethodneeding__strongattribute to override the default__autoreleasingas discussed here, etc.).So, probably best, just have a local variable that receives the update, and then invoke the property’s setter subsequent to that: