I have the following code:
In .h:
interface .... {
int CatID;
...
}
@property (readwrite) int CatID;
.m:
// Already includes the header file (.h)
implementation ... {
@synthesize CatID;
....
- (void)setCatIDa:(int)cid {
self.CatID = 20;
NSLog(@"cat id: %d", CatID); // this returns 20
}
- (IBAction)someTest:(id)sender {
NSLog(@"cat id: %d", CatID); // returns 0
}
}
How come its returning 0?
Also the NIB views are changing between the set and get
Without the complete code I can’t see exactly what would cause that behaviour, but I would point out a couple of things that could be improved and may have an impact.
If you could post the completed interface and implementation it’d be easier to test. I’ve written something very similar here and it works fine…