Reputation: 11340
I would like to add observer in my UIViewController for property in my application delegate.
is it possible like below code?
myAppDelegate *appDelegate = (myAppDelegate *)[[UIApplication sharedApplication] delegate] ;
[self addObserver:self
forKeyPath:appDelegate.currentLocation
options:0
context:nil];
the issue it expect the value for "forKeyPath" to be NSString.
Upvotes: 3
Views: 552
Reputation: 25318
myAppDelegate *appDelegate = (myAppDelegate *)[[UIApplication sharedApplication] delegate] ;
[appDelegate addObserver:self
forKeyPath:@"currentLocation"
options:0
context:nil];
Upvotes: 6