0
我在使用cordova 2.1.0框架的IOS中創建應用程序。我創建的Objective-C的sqlite3的分貝以下代碼:在Objective-C中創建數據庫時發生錯誤
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
self.databaseFile = [docDir stringByAppendingPathComponent:@"splistdb.sqlite3"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
if (![fileManager fileExistsAtPath:self.databaseFile]) {
/*[fileManager copyItemAtPath:[[NSBundle mainBundle] pathForResource:@"FriendsDatabase" ofType:@"sqlite3"] toPath:dbFileName error:&error];*/
NSString *path = [[NSBundle mainBundle] pathForResource:@"splistdb" ofType:@"sqlite3"];
NSLog(@"doc path=%@",path);
[fileManager copyItemAtPath:path toPath:self.databaseFile error:&error];
[self createConfigTable];
NSLog(@"database created");
} else {
NSLog(@"fail to create database");
}
我已經包含在libsqlite3.dylib編階段的文件標題。但我得到以下錯誤:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager copyItemAtPath:toPath:error:]: source path is nil'
我的代碼有什麼問題?謝謝。