1,document 中的路径 最麻烦的一种:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:filename;
本人自写自用的宏
2,#define ABS_FILE_PATH(FILE_NAME) [NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(),FILE_NAME]
3,获取程序application package目录下的文件路径:
#define PACKAGE_FILE_PATH(FILE_NAME) [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME]
4,NSString* filePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"fileType(txt...html..)"];
本文介绍了在iOS应用开发中获取不同类型的文件路径的方法,包括应用程序文档目录下的文件路径、自定义宏定义路径以及程序包资源路径等。通过具体代码示例展示了如何使用这些方法。
655

被折叠的 条评论
为什么被折叠?



