尝试使用以下代码清除UserDefaults(持久性数据)时:
var mainBundle:NSBundle = NSBundle.mainBundle()
var appDomain:NSString = mainBundle.bundleIdentifier!
userDefaults.removePersistentDomainForName(appDomain)
第三个语句不会编译但会产生Apple Mach-O Linker错误:
Ld /Users/Alexander/Library/Developer/Xcode/DerivedData/AD62-bxdlketythywrzhfutzehevdbmyx/Build/Products/Debug-iphonesimulator/AD62.app/AD62 normal x86_64
cd /Users/Alexander/Desktop/AD62
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
...
Undefined symbols for architecture x86_64:
"__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
__TFC4AD6226ProfileTableViewController13viewDidAppearfS0_FSbT_ in ProfileTableViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
感谢任何帮助。
答案 0 :(得分:0)
这有效:
var mainBundle:NSBundle = NSBundle.mainBundle()
userDefaults.removePersistentDomainForName(mainBundle.bundleIdentifier!)
我看不出有什么大不同,但就是这样。