iphone - Strange SQLite problem testing if column was returned -
The best part of me is what I'm doing on the results to show the code:
This works:
if (sqlite3_column_text (statement, 0)) {[Marker set object: [NSNumber numberHome: sqlite3_column_int (Statement, 0)] for KA: @ "id"] ; }
This is always wrong for the if statement:
if (sqlite3_column_int (statement, 0)) {[marker set object: [NSNumber numberWithInt : Sqlite3_column_int (statement, 0)] for: @ "id"]; }
This returns the wrong result for the column:
if (sqlite3_column_text (statement, 0)) {{marker set object: [NSNumber numberWithInt: Sqlite3_column_text (statement, 0)] for: @ "id"]; }
Any ideas what's going on?
You should meet the number of columns returned to the value of the column.
int count = sqlite3_column_count (statement);
When you say sqlite3_column_int (), it returns the integer value of the column. What if that value is zero? You can not tell the difference between a valid zero result and a zero value for that column. You can test that there is zero in one column
sqlite3_column_type () == SQLITE_NULL; In addition, OBJ-C does not automatically convert different types, so numberless: sqlite3_column_text
will definitely result in garbage results. Is sqlite3_column_text () returns an indicator for the C string, which is known in a memory stored in the string. I'm guessing that you're expecting to convert a string to an integer? It does not happen in C.
Comments
Post a Comment