I’m working on sqlite database on ios 5. What my application does is that it takes strings in a textfield and saves it to the database. When I run the app, it crashes giving this warning:
Thread1: Program Received Signal “SIGBRT”
It gives this in main.m and this line:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Can anyone help me with it? It’ll be highly appreciated! 🙁 I’m using xcode 4.2.
Here’s the method where the compiler says that assertion failure has occurred.
- (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);
}
It’s impossible to tell exactly what’s going on in your program without more information, but the most common reasons that abort() gets called are:
You have some memory stomping/allocation error. When malloc/free detect a corrupted heap, that may call abort().
That means that: You are freeing memory when it has already been done, probably by sending too many release messages to an object. Another thing is that you might have failed to connect an object to its IBOutlet in the nib. I can’t really tell since you haven’t given any other information aside from the reported error.
You’re throwing an uncaught exception (either a C++ exception or an Objective-C exception).
In almost all cases, the debug console will give you a little more information about what’s causing abort() to be called, so always take a look there.