I have this code:
.h
int cellsPerRow;
@property int cellsPerRow;
.m
@synthesize cellsPerRow;
-(void)init {
...
cellsPerRow = 4;
}
-(void)setCellsPerRow:(int)cellsPerRowLocal {
cellsPerRow = cellsPerRowLocal;
....
}
But the setter method isn’t being called. Any ideas why?
The property and synthesize create the setter and getter methods for you. In essence what you are doing is actually override the methods that were created for you in the first place.
Don’t do that. Just use dot notation, like so,
self.cellsPerRow = cellsPerRowLocal. This will set yourcellsPerRowivar to whatever you want it to be incellsPerRowLocal.In you header file:
In your implementation file: