NSUserDefault with application group not working in iOS 8 Beta3

I need to save the Boolean value to NSUserDefault in my application using the custom keyboard extension and share with the application group.

My code works in iOS 8 Beta1.

 self.defaults = [NSUserDefaults standardUserDefaults]; if([self.defaults boolForKey:@"BlackKey"]) { NSLog(@"Black"); } else { NSLog(@"White"); } 

But not in iOS 8 Beta3. When I retrieve a Boolean value from NSUserDefault , it does not return anything and I cannot load from a custom keyboard extension.

I also tried with initWithSuiteName in NSUserDefault . Am I the only one for this problem or iOS 8 Beta3 errors?

+3
source share
2 answers

Several possible solutions:

  • Your application group is not configured correctly or you are not using the correct group identifier with initWithSuiteName:

  • You have not enabled network access for your keyboard. This document states the following if network access is disabled for your keyboard (default behavior):

    Missing shared container with content

  • This is mistake.

+2
source

Try using

 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"BlackKey"]; 

when you save and read it using this code:

 if([[NSUserDefaults standardUserDefaults] boolForKey:@"BlackKey"]) { NSLog(@"Black"); } else { NSLog(@"White"); } 

or if you already did this, then it could be a bug, and there are other bugs in Xcode 6 beta too, so it’s safer to try it in Xcode 5 or later.

-5
source

Source: https://habr.com/ru/post/972342/


All Articles