我正在處理iOS 5上的sqlite數據庫。我的應用程序所做的是將文本字段中的字符串保存到數據庫中。當我運行的應用程序,它崩潰給這個警告:Thread1:程序接收到的信號「SIGBRT」
線程1:計劃接收信號 「SIGBRT」
它給出了這樣的main.m文件,這行:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
任何人都可以幫助我嗎?它將不勝感激! :(我使用的Xcode 4.2。
這裏就是編譯器說,已經發生斷言失敗的方法。
- (void) addstrings{
if(addStmt == nil) {
const char *sql = "insert into strings(strings) Values(?)";
if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_text(addStmt, 1, [strings UTF8String], -1, SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
//SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
strID = sqlite3_last_insert_rowid(database);
//Reset the add statement.
sqlite3_reset(addStmt);
}
「將其保存到數據庫」是指你直接調用SQLite還是使用CoreData?無論哪種情況,在保存點上看相關的代碼都會很有幫助。 – wadesworld
我正在使用sqlite 3 @wadesworld。我已經多次檢查了代碼,但沒有提示: –
您能否將堆棧跟蹤添加到問題中 – JeremyP