我是 iPhone 的初学者,我已经创建了数据库,但是运行时错误为 Failed to create writable database file with message 'The operation could not be completed
我的代码是
-(void)createdatabase
{
NSFileManager *fileManager=[NSFileManager defaultManager];
NSError *error;
NSString *dbPath=[self getDBPath];
BOOL success=[fileManager fileExistsAtPath:dbPath];
if(!success)
{
NSString *defaultDBPath=[[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"SQL.sqlite"];
success=[fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if(!success)
{
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
}
给出适用于我的代码的任何建议和源代码