I have one class as Model – Filter. I need to access this model from my controller.
Filter.h
@interface Filter : NSObject
@property (nonatomic, assign) BOOL name;
@end
In my controller:
@implementation NavigationController
@synthesize filter = _filter;
- (IBAction)setVirtualShowProperty:(UISwitch*)sender {
self.filter.virtualRoomSet = YES;
_filter.virtualRoomSet = YES; // I dont know which syntax is better
}
@end
But it doesnt update virtualRoomSet it is still ‘NO’. Where is bug? Thanks
It looks like you’re calling setVirtualShowProperty: before calling navigationController.filter = someFilter;.
The fact that you’re setting your boolean value to YES and still seeing it be NO is misleading – it’s not really NO, it’s just that the object you’re setting it on is probably nil.
You should ensure that your navigationController.filter object is indeed not nil when you get to setVirtualShowProperty:.