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 = 1 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications
NSDemoApplicationDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications/Demos
NSDeveloperApplicationDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Developer/Applications
NSAdminApplicationDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications/Utilities
NSLibraryDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/
NSDeveloperDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Developer
NSUserDirectory nil
NSDocumentationDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Documentation
NSDocumentDirectory file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Documents/
NSCoreServiceDirectory nil
NSAutosavedInformationDirectory = 11 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Autosave%20Information
NSDesktopDirectory = 12 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Desktop
NSCachesDirectory = 13 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Caches/
NSApplicationSupportDirectory = 14 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Application%20Support
NSDownloadsDirectory = 15 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Downloads
NSInputMethodsDirectory = 16 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/Input%20Methods
NSMoviesDirectory = 17 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Movies
NSMusicDirectory = 18 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Music
NSPicturesDirectory = 19 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Pictures
NSPrinterDescriptionDirectory = 20 nil
NSSharedPublicDirectory = 21 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Public
NSPreferencePanesDirectory = 22 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/PreferencePanes
NSItemReplacementDirectory = 99 nil
NSAllApplicationsDirectory = 100 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Applications
NSAllLibrariesDirectory = 101 file://localhost/Users/hemarcus/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/00F96338-26D1-491D-8BA7-E97663752A1F/Library/
那么NSSearchPathDomainMask不是NSUserDomainMask时能使用urlForDirectoryxxx方法吗??iOS下有啥不同??

NSSearchPathDomainMask URLForSearch=NSLibraryDirectory URLForSearch=NSApplicationDirectory URLForSearch=NSDemoApplicationDirectory
NSLocalDomainMask = 2 file://localhost/Library/ file://localhost/Applications/ file://localhost/Applications/Demos
NSNetworkDomainMask = 4 file://localhost/Network/Library file://localhost/Network/Applications file://localhost/Network/Applications/Demos
NSSystemDomainMask = 8 file://localhost/System/Library/ file://localhost/Applications/ file://localhost/Applications/Demos
NSAllDomainsMask = 0x0ffff 同NSUserDomainMake返回值 同NSUserDomainMake返回值 同NSUserDomainMake返回值

扫描二维码关注公众号,回复: 11921865 查看本文章

猜你喜欢

转载自blog.csdn.net/Marcus2006/article/details/18461243