In my app I want to support the sqlite3 DB having NULL values in the DB for the items that should be NULL (i.e. non-edited data).
So I have my sqlite3 DB all created and filled with data, my app loads beautifully and there aren't any problems. For the varchar fields I want to be NULL I have currently put in a ' ' (space).
I am now at a point where I need to fix my data in the DB to really be NULL if it should be empty (instead of the ' ' (space) placeholder I have put in).
So I have modified my sqlite3 DB data with Firefox SQLite Manager and reset my iPhone Simulator. The app launches, copies the new DB as it doesn't exist... But I don't know how to handle the NULL when I read in from the DB. I do a:
2009-01-15 18:28:38.987 iApp[1170:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
I understand that the column I have has NULL data - that is what I want. But I do not know how to pre-determine that it is NULL so I can just set self.Locality to nil.
char *aCurrencyCoin = (char *)sqlite3_column_text(compiledStatement, 44); //Conflicting types for "aCurrencyCoin"
if (aCurrencyCoin ==null) // null undeclared
aCurrencyCoin = nil;
else
aCurrencyCoin = [NSString stringWithUTF8String: aCurrencyCoin];
Country *country = [[Country alloc] initWithName:aName CurrencyCoin:aCurrencyCoin ]; // there is a lot more added to the array from earlier code.
I get the above errors:
Can anyone see where I am doing this wrong.
__________________
Many thanks, keep safe and well.
The function sqlite3_column_text returns a char pointer; is Country initWithName:CurrencyCoin: expecting a NSString? They're two different types. The 'Conflicting types' is probably coming up if you declare "aCurrencyCoin" as two different type, possibly one in the .h and on in the method?
Still getting errors. The code below is a portion of the complete code.
In the .h I have "NSString *CurrencyCoin;" and "@property (nonatomic, retain) NSString *CurrencyCoin;".
The error now is"passing argument 1 of 'stringWithUTF8String:' from incompatible pointer type"