我需要在我的iOS自定義鍵盤中將數據保存到NSUserDefault
。 我已經在開發者門戶網站成功創建了應用組和權利,並且XCode
。NSUserDefault無法在iOS8中保存並加載擴展名
這是我如何保存我的價值與UISwitch
- (IBAction)switchAction:(id)sender
{
[self.defaults setBool:self.myKey.on forKey:@"myValue"];
[self.defaults synchronize];
}
,這裏是我如何KeyboardView負荷值。
self.defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.mycompany.customkeyboard"];
if([self.defaults boolForKey:@"myValue"])
{
self.backgroundColor = [UIColor redColor];
}
else
{
self.backgroundColor = [UIColor blackColor];
}
這是行不通的,不會加載值。
如何保存和加載數據?
[應用程序組與應用程序之間的數據通信和持久化](http://stackoverflow.com/questions/24015506/communicating-and-persisting-data-between-apps-with-app-groups) –
否我已經發現了這些問題。我的問題是我不知道如何從NSUserDefault加載數據。 –
我指的是[我對該問題的回答](http://stackoverflow.com/a/24063144/2446155),我稍微修改並在下面進行了複製。 –