Why won't my app run in XCode 8 beta (8S128d)

风流意气都作罢 提交于 2019-12-01 06:53:31

问题


This is an issue that will affect many apps, and can be found in Xcode 8 beta (8S128d). This is the first beta, although it is not labelled beta 1.

The issue is with NSUserDefaults; it doesn't work. Here's the code, maybe put it in application:didFinishLaunchingWithOptions:.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:@"hello world" forKey:@"TEST"];

[defaults synchronize];

NSString * oops = [[NSUserDefaults standardUserDefaults] valueForKey:@"TEST"];
NSLog(@"default = %@", oops);

In XCode 7 and earlier, this code works as expected: the value of oops is "hello world".

In XCode 8, the value of oops is nil.

That's pretty major!


回答1:


Found the answer: https://forums.developer.apple.com/message/143155#143155

If you've used XCode 7 or earlier, you need to reboot the Mac before running the iOS 10 simulator.

From the release notes:

WWDC Seed: Running multiple iOS simulators can cause NSUserDefaults to not work

Running an iOS 8 or 9 simulator followed by an iOS 10 simulator will cause NSUserDefaults to stop working in the simulator. This can be worked around by rebooting the host Mac.



来源:https://stackoverflow.com/questions/37824190/why-wont-my-app-run-in-xcode-8-beta-8s128d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!