NSSearchPathForDirectoriesInDomain函数使用
来源:互联网 发布:淘宝问卷调查报告 编辑:程序博客网 时间:2024/06/05 05:35
/* 在指定目录下搜索指定文件的路径 * * directory 要搜索的目录的名称 * domainMask 搜索范围 * expandTilde 是否扩展路径,YES->获取完整路径,一般为YES * * return 返回值为数组,一般得到的是唯一的路径,所以直接取第一个就行了 * * 注:以下附参数可选值列表 */ //NSArray<NSString *> *NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde); //在沙盒中获取Documents的完整路径 NSString * path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; //得到path下test文件的路径 NSString * filePath = [path stringByAppendingPathComponent:@"test"]; //判断test文件是否存在 NSFileManager * fm = [NSFileManager defaultManager]; if ([fm fileExistsAtPath:filePath]) { NSLog(@"test文件存在"); }else{ NSLog(@"test文件不存在"); } //参数列表 //NSSearchPathDirectory typedef NS_ENUM(NSUInteger, NSSearchPathDirectory) { NSApplicationDirectory = 1, // supported applications (Applications) NSDemoApplicationDirectory, // unsupported applications, demonstration versions (Demos) NSDeveloperApplicationDirectory, // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory. NSAdminApplicationDirectory, // system and network administration applications (Administration) NSLibraryDirectory, // various documentation, support, and configuration files, resources (Library) NSDeveloperDirectory, // developer resources (Developer) DEPRECATED - there is no one single Developer directory. NSUserDirectory, // user home directories (Users) NSDocumentationDirectory, // documentation (Documentation) NSDocumentDirectory, // documents (Documents) NSCoreServiceDirectory, // location of CoreServices directory (System/Library/CoreServices) NSAutosavedInformationDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 11, // location of autosaved documents (Documents/Autosaved) NSDesktopDirectory = 12, // location of user's desktop NSCachesDirectory = 13, // location of discardable cache files (Library/Caches) NSApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support) NSDownloadsDirectory NS_ENUM_AVAILABLE(10_5, 2_0) = 15, // location of the user's "Downloads" directory NSInputMethodsDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 16, // input methods (Library/Input Methods) NSMoviesDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 17, // location of user's Movies directory (~/Movies) NSMusicDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 18, // location of user's Music directory (~/Music) NSPicturesDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 19, // location of user's Pictures directory (~/Pictures) NSPrinterDescriptionDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 20, // location of system's PPDs directory (Library/Printers/PPDs) NSSharedPublicDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 21, // location of user's Public sharing directory (~/Public) NSPreferencePanesDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes) NSApplicationScriptsDirectory NS_ENUM_AVAILABLE(10_8, NA) = 23, // location of the user scripts folder for the calling application (~/Library/Application Scripts/code-signing-id) NSItemReplacementDirectory NS_ENUM_AVAILABLE(10_6, 4_0) = 99, // For use with NSFileManager's URLForDirectory:inDomain:appropriateForURL:create:error: NSAllApplicationsDirectory = 100, // all directories where applications can occur NSAllLibrariesDirectory = 101, // all directories where resources can occur NSTrashDirectory NS_ENUM_AVAILABLE(10_8, NA) = 102 // location of Trash directory }; //NSSearchPathDomainMask typedef NS_OPTIONS(NSUInteger, NSSearchPathDomainMask) { NSUserDomainMask = 1, // user's home directory --- place to install user's personal items (~) NSLocalDomainMask = 2, // local to the current machine --- place to install items available to everyone on this machine (/Library) NSNetworkDomainMask = 4, // publically available location in the local area network --- place to install items available on the network (/Network) NSSystemDomainMask = 8, // provided by Apple, unmodifiable (/System) NSAllDomainsMask = 0x0ffff // all domains: all of the above and future items };
0 0
- NSSearchPathForDirectoriesInDomain函数使用
- 使用函数
- 函数使用
- 使用函数
- 函数与函数使用
- 跨函数使用malloc函数
- 函数:使用函数指针操作函数
- lua 函数 使用 lua 函数 高级使用
- struts 标签使用 使用函数
- memset函数 memcpy函数 memcmp函数------ 函数使用笔记
- Win32函数使用笔记
- 使用通用函数
- 简单使用_dopostback函数
- 使用excel的函数
- 第一次使用函数指针
- 仿函数使用要领
- format函数的使用
- format函数的使用
- LeetCode-415. Add Strings
- Jenkins QuickStart
- 零基础写Java知乎爬虫之进阶篇
- JS rotate
- photoshop第十六章:制作商业广告效果
- NSSearchPathForDirectoriesInDomain函数使用
- [多线程学习]2017.02.21
- 【ZIP格式分析】 文件名乱码
- FastJson的简单使用
- 如何判断当前界面是否属于某个apk,或具体到某个Activity
- ASM 翻译系列第四弹:高级知识kfed元数据编辑器
- Longest Palindromic Substring--求字符串最长回文子串
- android使用startActivityForResult跳转Activity并回传值
- pfx证书提取公私钥的方法