I am storing a collection of values in a table with several columns of different types, and inserting and selecting works fine when I run the app on the iPhone simulator. However, when running on a real device and selecting the data, it looks like it fails to get some of the text columns of the table (rest of columns seem to be correctly retrieved). Where I should be shown a dialog with a string, I am not, I get an empty dialog, whereas the dialog with the string was properly displayed on the simulator.
This is the code snippet for the insertion:
if(sqlite3_prepare_v2(database, sqlStatement,
-1, &compiledStatement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(compiledStatement, 1, userData.ID);
sqlite3_bind_double(compiledStatement, 2, userData.Location.Lat);
sqlite3_bind_double(compiledStatement, 3, userData.Location.Lon);
sqlite3_bind_text(compiledStatement, 4, [userData.Name UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 5, [userData.Surname UTF8String], -1, SQLITE_TRANSIENT);
}
if(sqlite3_step(compiledStatement) == SQLITE_DONE) {
sqlite3_finalize(compiledStatement);
}
else {
NSLog(@"%d",sqlite3_step(compiledStatement));
}
}
sqlite3_close(database);
And this is the selection:
if (sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
UserData *userData = [[UserData alloc] init];
userData.ID = sqlite3_column_int(compiledStatement, 0);
char *name = sqlite3_column_text(compiledStatement, 1);
if (name == nil)
userData.Name = @"";
else
userData.Name = [NSString stringWithUTF8String: name];
[list addObject:userData];
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
I have absolutely no idea why database data management is behaving well in simulator (I have SQLite Manager plugin and data is correctly stored and retrieved), but it is not in a real iPhone. How could I check what is happening there on the device? Has somebody experienced something similar to this?
Thanks!
I finally got it working, following all your advices, and I think what solved the problem in the end was the case-sensitive thing. Thanks to u all