iOS获取沙盒目录+URLForDirectory:inDomain:appropriateForURL:create:error: NSFileManager

参考:

1. http://stackoverflow.com/questions/13983091/nsfilemanager-urlsfordirectory-or-urlfordirectory

2. http://blog.csdn.net/enuola/article/details/8076221

目的:

其实参考里已经介绍了获取沙盒路径方法,但是我很想知道的是用NSUserDomainMask时,使用不同NSSearchPathDirectory 我的iOS返回是什么?

Environment: Mount Lion ,Xcode 4.5.3 , cocos2d-iphone V2.0


NSSearchPathDirectory值实际ios返回值
NSApplicationDirectory = 1file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications
NSDemoApplicationDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications/Demos
NSDeveloperApplicationDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Developer/Applications
NSAdminApplicationDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications/Utilities
NSLibraryDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/
NSDeveloperDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Developer
NSUserDirectorynil
NSDocumentationDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Documentation
NSDocumentDirectoryfile://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Documents/
NSCoreServiceDirectorynil
NSAutosavedInformationDirectory = 11file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Autosave%20Information
NSDesktopDirectory = 12file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Desktop
NSCachesDirectory = 13file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Caches/
NSApplicationSupportDirectory = 14file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Application%20Support
NSDownloadsDirectory = 15file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Downloads
NSInputMethodsDirectory = 16file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Input%20Methods
NSMoviesDirectory = 17file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Movies
NSMusicDirectory = 18file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Music
NSPicturesDirectory = 19file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Pictures
NSPrinterDescriptionDirectory = 20nil
NSSharedPublicDirectory = 21file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Public
NSPreferencePanesDirectory = 22file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/PreferencePanes
NSItemReplacementDirectory = 99nil
NSAllApplicationsDirectory = 100file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications
NSAllLibrariesDirectory = 101file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/
那么NSSearchPathDomainMask不是NSUserDomainMask时能使用urlForDirectoryxxx方法吗??iOS下有啥不同??

NSSearchPathDomainMaskURLForSearch=NSLibraryDirectoryURLForSearch=NSApplicationDirectoryURLForSearch=NSDemoApplicationDirectory
NSLocalDomainMask = 2file://localhost/Library/file://localhost/Applications/file://localhost/Applications/Demos
NSNetworkDomainMask = 4file://localhost/Network/Libraryfile://localhost/Network/Applicationsfile://localhost/Network/Applications/Demos
NSSystemDomainMask = 8file://localhost/System/Library/file://localhost/Applications/file://localhost/Applications/Demos
NSAllDomainsMask = 0x0ffff同NSUserDomainMake返回值同NSUserDomainMake返回值同NSUserDomainMake返回值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值