views:

18

answers:

1

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'

A: 

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];
Nikolai Ruhe