xcode NSuserdefaults 位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36006110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NSuserdefaults Location
提问by ios newbie
I cant find location of nsuserdefaults for my app. In same questionsolution was /users/your user name/Library/Application Support/iPhone Simulator//Applications. But i have no in iPhone Simulatar dir.
我找不到我的应用程序的 nsuserdefaults 位置。在同一问题的解决方案是 /users/您的用户名/Library/Application Support/iPhone Simulator//Applications。但我在 iPhone Simulatar 目录中没有。
回答by Reshmi Majumder
You can do this
你可以这样做
Search for documents directory path
搜索文档目录路径
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSLog(@"documentsDirectory=%@",documentsDirectory);
That will come as
那将是
/Users/user/Library/Developer/CoreSimulator/Devices/270568AE-FB4B-4C57-8819-4D99324D0689/data/Containers/Data/Application/C614A497-971F-4686-9162-3A614AB2C702/Documents
now go upto
现在去
/Users/user/Library/Developer/CoreSimulator/Devices/270568AE-FB4B-4C57-8819-4D99324D0689/data/Containers/Data/Application/C614A497-971F-4686-9162-3A614AB2C702
Then
然后
/Library/Preferences/....plist
.plist file stores NSUserdefaults content under Root .
.plist 文件将 NSUserdefaults 内容存储在 Root 下。
回答by Victor Bogdan
When using the Simulator, you can use this swift snippet to print the location :
使用模拟器时,您可以使用此 swift 代码段打印位置:
dump(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
dump(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
回答by Kumar Utsav
The physical path is rootOfApplication/Library/Preferences/com.yourcompany.appName.plistyou can see there if you test it in simulator
物理路径是 rootOfApplication/Library/Preferences/ com.yourcompany.appName.plist如果你在模拟器中测试它你可以看到那里
and the workflowis
和工作流程是
1.Connect Your device to Xcode
1.将您的设备连接到Xcode
2.select Windows->Organiser
2.选择Windows->组织者
3.select you device
3.选择你的设备
4.tap on your application
4.点击您的应用程序
5.select applicationData tapping down list
5.select applicationData 点击下拉列表
6.tap down arrow and download that folder
6.点击向下箭头并下载该文件夹
7.open downloaded folder Library -> Preferences -> appbundlename.plist
7.打开下载的文件夹Library -> Preferences -> appbundlename.plist