I have been trying to figure out why the Analyzer in Xcode seems to like the this code, so maybe someone can see what is wrong. Gives me this message: “Function call argument is an uninitialized value”.
It has a problem with this line and complains about the “statement”:
if (sqlite3_exec(MysDB, delete_stmt, NULL, statement, NULL) == SQLITE_OK) {
Actual Code:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &MyDB) == SQLITE_OK)
{
NSString *deleteSQL = [NSString stringWithFormat:@"DELETE FROM DATATABLE WHERE ID = %d", recordID];
const char *delete_stmt = [deleteSQL UTF8String];
if (sqlite3_exec(MysDB, delete_stmt, NULL, statement, NULL) == SQLITE_OK) {
NSLog(@"Deleted");
}else{
NSLog(@"Not Deleted");
}
sqlite3_close(MyDB);
}
}
More Code Here Removed on Purpose...
}
The 3rd parameter of sqlite3_exec is the callback function, which is currently NULL in your example. And the 4th parameter is the argument to this callback.
http://www.sqlite.org/c3ref/exec.html
So, I think it doesn’t like the fact that you’re giving an actual argument to a NULL callback function.