把sqlite数据库加到程序里面在mac上面运行的时候可以成功复制到Document目录下,但是我联机到iphone上去的时候就是没有复制,有遇到这种问题的么?能帮忙解决下么?// NSString *localDBPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Golf.sqlite3"];
// if (![[NSFileManager defaultManager] fileExistsAtPath:localDBPath]) {
// NSString *bundleDBPath = [[NSBundle mainBundle] pathForResource:@"Golf" ofType:@"sqlite3"];
// [[NSFileManager defaultManager] copyItemAtPath:bundleDBPath toPath:localDBPath error:nil];
// }

解决方案 »

  1.   

    其实我想知道你怎么测试说没有复制成功的?
    你再次用if (![[NSFileManager defaultManager] fileExistsAtPath:localDBPath]) 判断了?
      

  2.   

    测试没有成功的意思是说我在mac上面复制之后可以调用数据,但是在iphone上面怎么就不行呢???上面那个代码也是你给我的,但是在mac上面运行了!iphone不行,用不用if (![[NSFileManager defaultManager] fileExistsAtPath:localDBPath])这句好像都不行!
      

  3.   

    我的意思是你验证一下iPhone上文件是否存在
      

  4.   

    http://b80.photo.store.qq.com/http_imgload.cgi?/rurl4_b=3a6fd8ba77a44148ed54bece782f3ab9769b195aa1b28a041b2403663919c5b234049d575435bd7ff9430a42dbf5cb37e05788324fda805baed30728e92e2306d3df7f0e75940e02433bdfee30abce6608166616&a=80&b=80
      

  5.   

    http://b80.photo.store.qq.com/http_imgload.cgi?/rurl4_b=3a6fd8ba77a44148ed54bece782f3ab9769b195aa1b28a041b2403663919c5b234049d575435bd7ff9430a42dbf5cb37e05788324fda805baed30728e92e2306d3df7f0e75940e02433bdfee30abce6608166616&a=80&b=80