You can wrap BOOL in NSNumber, for example, bandejapaisa and beryllium. However, to notify observers about changes to a simple property, you better use Key Value Observing (KVO) instead of NSNotificationCenter. You get KVO βfor freeβ as long as you have implemented or @synthesized KVC-compliant access methods. Something like that:
// In your .h: @interface YourViewController : UIViewController @property (getter = isFullScreen) BOOL fullScreen; @end // In your .m: @implementation YourViewController @synthesize fullScreen; @end // In your observer class(es): // Start observing the viewController for changes to fullScreen (in awakeFromNib, or wherever it makes sense) [self.viewController addObserver:self forKeyPath:@"fullScreen" options:0 context:NULL]; // This method is called when an observed value changes - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == viewController && [keyPath isEqualToString:@"fullScreen"]) { if (self.viewController.isFullScreen) { // Do whatever you need to do in response to isFullScreen being true } else { // Do whatever you need to do in response to isFullScreen being false } } }
For this to work, you need to make sure that you are really calling setter on the fullScreen property. Therefore, always self.fullScreen = YES [self setFullScreen:YES] instead of fullScreen = YES . Otherwise, the setter method is not called, and KVO does not start.
You should read the KVO documentation. Understanding this is quite fundamental in order to be a good iOS programmer.
source share