XCode 4.2を使用してiphoneアプリを作成しています。私はアプリケーションのためのsqlite3データベースを使用しています。 iPhone 3GSとXCode 3.2.5で、XCode 4.2に問題が発生したときに、このアプリケーションを作成して正常に実行しました。 dbファイルを開くことができません、ここでは、テーブルを開くためのサンプルコードコードです。そして、私はSQliteマネージャを使って同じdbファイルを開いたとき、私はテーブルを見ることができました。私はエラーが何であるか分かりません。Sqlite3データベースXCode 4.2で表を開くことができません
static sqlite3 *database = nil;
static sqlite3_stmt *selectStmt = nil;
+ (void) getInitialDataToDisplay:(NSString *)dbPath {
NSLog(@"Path: %@",dbPath);
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
NSString *sqlStr = @"select * from Space";
const char *sql = [sqlStr UTF8String];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
SpaceClass *spaceObj = [[SpaceClass alloc] initWithPrimaryKey:primaryKey];
spaceObj.spacePK = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
spaceObj.spName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 3)];
spaceObj.spDescrptn = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 4)];
[appDelegate.spaceArray addObject:spaceObj];
[spaceObj release];
}
}else
NSLog(@"not ok");
}
else
sqlite3_close(database); //Even though the open call failed, close the database connection to release all the memory.
}
、感謝
'NSLog(@" Error =%s "、sqlite3_errmsg(&db))'は何を確認できますか? – iNoob