为什么我的应用程序不能在XCode

为什么我的应用程序不能在XCode

本文介绍了为什么我的应用程序不能在XCode 8 beta(8S128d)中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个会影响许多应用程序的问题,可以在Xcode 8 beta(8S128d)中找到.这是第一个Beta,尽管它没有标记为beta 1.

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.

问题出在NSUserDefaults上;它不起作用.这是代码,也许将其放在 application:didFinishLaunchingWithOptions:中.

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);

在XCode 7和更早的版本中,此代码按预期工作: 的值为"hello world".

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

在XCode 8中, oops 的值为 nil .

In XCode 8, the value of oops is nil.

这很重要!

推荐答案

找到了答案:https://forums.developer.apple.com/message/143155#143155

如果您使用过XCode 7或更早版本,则需要在运行iOS 10模拟器之前重新引导Mac.

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

WWDC种子:运行多个iOS模拟器可能导致NSUserDefaults无法正常工作

WWDC Seed: Running multiple iOS simulatorscan cause NSUserDefaults to not work

运行iOS 8或9模拟器其次是iOS 10模拟器将导致NSUserDefaults停止在模拟器中工作.可以通过重新启动托管Mac.

Running an iOS 8 or 9 simulatorfollowed by an iOS 10 simulator will cause NSUserDefaults to stopworking in the simulator. This can be worked around by rebooting thehost Mac.

这篇关于为什么我的应用程序不能在XCode 8 beta(8S128d)中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:57