FMDB,真机调试为什么无法写入

zoom28 发布于 2016/02/17 13:10
阅读 101
收藏 0

模拟器上运行正常,但到真机运行时,就无法写入

NSFileManager *filemanager=[[NSFileManager alloc]init];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
    NSString *documentDirectory = [paths objectAtIndex:0];
    [filemanager removeItemAtPath:documentDirectory error:nil];
    
    NSString * db1Path = [documentDirectory stringByAppendingString:@"OtherNewsData.db"];
    
     [[NSFileManager defaultManager] setAttributes:[NSDictionary dictionaryWithObject:NSFileProtectionNone forKey:NSFileProtectionKey] ofItemAtPath:documentDirectory error:NULL];
    
    _homeNewsBD = [FMDatabase databaseWithPath:db1Path];
    NSLog(@"%@",db1Path);
    
    [_homeNewsBD open];
    
    [_homeNewsBD executeUpdate:@"CREATE TABLE IF NOT EXISTS WHList (id integer PRIMARY KEY AUTOINCREMENT,Source text, Title text, Site text, Image text)"];
    NSLog(@"已经创建数据库");
    [_homeNewsBD close];
    if ([filemanager fileExistsAtPath:db1Path]) {
        NSLog(@"成功创建数据库");
    }



加载中
返回顶部
顶部