I am trying to use the App Groups Entitlement in my app for NSUserDefaults handling data between the iPhone app and the WatchKit Extension.
I went to Capabilities in the iPhone target, and turned on App Groups, and made sure that group.com.316apps.iPrayed was selected. I then went to the WatchKit Extension Target and did the same for its Capabilities.
On the iPhone side of the app I put in the following code:
PFUser *me2 = [PFUser currentUser];
NSLog(@"USERNAME%@", me2.username);
NSUserDefaults *testDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.316apps.iPrayed"];
[testDefaults setObject:me2.username forKey:@"username"];
[testDefaults setObject:me2.password forKey:@"password"];
[testDefaults synchronize];
In the WatchKit InterfaceController, I have the following, but the NSLog always shows 'null'
NSUserDefaults *testDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.316apps.iPrayed"];
NSString *theirUser = [testDefaults objectForKey:@"username"];
NSString *theirPass = [testDefaults objectForKey:@"password"];
NSLog(@"%@", theirUser);
Why is the WatchKit not reading the NSUserDefaults properly?
NOTE My bundle identifier is different for the watch kit extension target. Do I need a new Apple ID for that?