I encountered a behavior that wasn't familiar.
I searched on the Internet, and more precisely on StackOverflow, and found a lot of articles and posts about readonly properties.
I feel like there is a massive and invisible learning experience concerning compilation process and assignment/declaration/initialization.
I really want to clearly understand those situations.
Imagine I have a property
@property (nonatomic, strong) CLLocation *location;
I have stored in my NSUserDefault
the last known user location as a String.
If I want to set the coordinate of my location property with my lastLocation I have a compilation error :
Assignment to readonly property
Here is my line of code :
_location.coordinate = [[MyCustomUserDefaults lastLocation] doubleValue];
Here is my NSUserDefaults getter :
+(NSString *) lastLocation
{
return [[NSUserDefaults standardUserDefaults] objectForKey:USER_PREF_LAST_LOCATION];
}