This is my code
NSString *enddate = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
I need to have null dates, but when a null is passed to this line, I get an error
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSPlaceholderString initWithUTF8String:]: NULL cString'
You cannot initialize NSString objects with a NULL pointer so just check for that condition:
const char* date = (const char*)sqlite3_column_text(statement, 3);
NSString *enddate = date == NULL ? nil : [[NSString alloc] initWithUTF8String:date];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With