【发布时间】:2012-07-12 07:32:37
【问题描述】:
我为我的应用创建了一个包含数据的 sqlite 数据库,并将其拖到 Xcode 中的支持文件组中。
当我尝试使用以下方式访问它时:
NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"];
它不读取文件。但是,如果我输入完整的文件路径:
NSString *bundlePath = @"Users/xxxx/Apps/App/database.db";
该应用运行良好。
我从以下位置打印出文件路径:
NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"];
它是:
/Users/xxx/Library/Application Support/iPhone Simulator/5.1/Applications/EE614EFA-BAF9-478E-xxxx-xxxx/App.app/database.db
有什么想法吗?
【问题讨论】: