Is it possible to add observers to simple variables such as BOOLs or NSIntegers and see when they change?
Thanks!
I believe what you meant was: How to get INT or BOOL value from the 'change' dictionary if the property has changed.
You can simply do it this way:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqualToString:@"mySetting"])
{
NSNumber *mySettingNum = [change objectForKey:NSKeyValueChangeNewKey];
BOOL newSetting = [mySettingNum boolValue];
NSLog(@"mySetting is %s", (newSetting ? "true" : "false"));
return;
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}