I'm creating a Watch app just to display a value on the watch when the user taps on a table view in the iPhone/host app.
I would like to get a notification the value changes on a shared UserDefault. It is shared between WatchKit app and the iOS (host) app, so when the user makes any changes in the host app I'm expecting to get the notification. I've done the following:
When user do some action in application (host app):
NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:@"group.app"];
id object = [self.plantsArray objectAtIndex:[self.plantsTable indexPathForSelectedRow].row];
[shared setObject:object forKey:@"data"];
[shared synchronize];
In the Watchkit extension have registered for the notification:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(print) name:NSUserDefaultsDidChangeNotification object:nil];
but unfortunately I'm not getting any notification, has anyone a solution?