The value of YES
does get there, but that happens after you have printed the default NO
.
The current value of _myProperty
is printed in the initializer; by the time you assign the property YES
, the initializer is done!
You can check that the value does get there by adding a method to show the current value of the property:
- (id)showMyProperty {
myLocalProperty = _myProperty;
if (myLocalProperty==YES) {
NSLog(@"YES");
} else if (myLocalProperty==NO) {
NSLog(@"NO");
}
}
Now change your code that creates CustomView
as follows:
CustomView *myView = [[CustomView alloc] initWithFrame:CGRectZero];
myView.myProperty=YES;
[myView showMyProperty]; // This should produce a "YES" in NSLog