iOS__获取项目下面的文件路径
2017-10-10 本文已影响3030人
CoderJohnhao
获取工程项目中文件夹或者文件的路径
- 将文件拖入项目中,选择Create Folder References,点击Finish(如下图)

2.将拖入的文件添加到Copy Bundle Resource,具体步骤如下图:


3.获取文件的代码:
// 获取文件路径
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"文件名"ofType:@"文件类型"];
// 获取文件夹下的文件路径
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"文件类型" inDirectory:@"文件夹名"];