ios - WatchKit NSUserDefaults are null -


doing real basic test in setting / receiving data using nsuserdefaults. iphone app working , setting data fine, on watch, it's coming null.

i have app group enabled both , have verified identical using same group. entitlement files each bit bit same.

in viewcontroller.m

    defaults = [[nsuserdefaults alloc] initwithsuitename:@"com.defaultmethod.share"];  [defaults setobject:playername forkey:@"playername"]; [defaults synchronize]; 

in interfacecontroller.m

- (void)awakewithcontext:(id)context {     [super awakewithcontext:context];      // configure interface objects here.     defaults = [[nsuserdefaults alloc] initwithsuitename:@"com.defaultmethod.share"];     [defaults synchronize]; }  - (void)willactivate {     // method called when watch view controller visible user     [super willactivate];      nslog(@"playername: %@", [defaults objectforkey:@"playername"]); } 

and is:

playername: (null)

i've got missing obvious. when nslog on iphone side, comes out fine, know it's saving correctly.

you need make sure following setting in proper place.

  • check entitlement.plist file application , watch kit extension, should have same app group identifier.
  • ensure selected correct development team under info section of each target.
  • you have correct mobile provisioning profiles installed

you can test these setting under capabilities section of app , watchkit extension target.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -