In the code below:
- (void)viewDidLoad {
NSArray *array = [[NSArray alloc] initWithObjects: @"Browny", @"Andy", @"Chiki", @"Gillu",
@"SnowLeopard", @"Lion", @"Tiger", @"SiberianTiger", nil ];
self.pickerData = array;
[array release];
}
if I change in above self.pickerData to pickerData, the program crashes with EXC_BAD_ACCESS signal received.
I thought for member variables/properties of the object using keyword self was optional?
Any hints, why I need self here, even though pickerData is a member variable of the class?
To wrap it up in one answer instead of dotted across the other answers.
When you call
this is compiled to
If you
@sythesizepickerDatathe implementation will do something similar to:So the difference is that
self.pickerData = arraywill go through the setter that will do the correct memory management whereaspickerData = arrayassigns the value directly.