ios bundle

第一种:把资源文件整合到.bundle里面统一管理

1 创建一个文件夹 MyBundle

2.把资源文件放进去

3.然后重命名 MyBundle.bundle

4.添加到project里面

5.读取MyBundle.bundle 里面的test.sqlite文件,如果不指定inDirectory,path为nil

NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"sqlite" inDirectory:@"MyBundle.bundle"];

第二种:直接在project里面创建一个group "Data"

1.添加test.sqlite文件到Data group里面

2.读取,不需要指定inDirectory

NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"sqlite"];

 

 

 /Users/zhanglei/Library/Developer/CoreSimulator/Devices/C8423A4F-BD2C-4995-A9E4-77BB382F3DF8/data/Containers/Bundle/Application/B3E6D1E8-FE8E-428B-BA61-53308C920CAB/sqlite.app/Data.bundle/test.sqlite

 

posted on 2015-12-14 16:19  StanleyZhang  阅读(154)  评论(0编辑  收藏  举报