please please i need help..i think i am lost somewhere..basically i followed the example http://www.iphonesdkarticles.com/2008/10/sqlite-tutorial-loading-data-as.html, but i was stuck with error on reading description..something must had gone wrong some well but i am not very sure how should i solve it. this is my code, actually i dun really have an idea on wat's really going in this code..help please..2days!! no solution!!
- (void) hydrateDetailViewData {
//if detail view is hydrated then do not get it from database
if(isDetailViewHydrated) return;
if(detailStmt == nil) {
const char *sql = "select snapTitle, snapDesc from Snap where snapID =?";
if(sqlite3_prepare_v2(database, sql, -1, &detailStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating detail view statement. '%s'", sqlite3_errmsg(database));
NSLog(@"SQLite= %d", sqlite3_step(detailStmt));
}
if(SQLITE_DONE != sqlite3_step(detailStmt)) {
// NSString *descStr = [[NSString alloc]
//initWithString:sqlite3_column_text(detailStmt, 2)];
NSString *descStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt,2)];
self.snapDescription = descStr;
[descStr release];
}
else
NSAssert1(0, @"Error getting description of snap2play. '%s'", sqlite3_errmsg(database));
sqlite3_reset(detailStmt);
isDetailViewHydrated = YES; //if hydrated, make sure do not get from database again.
}
}
Error message: 2010-03-12 16:17:14.377 Snap2Play[51282:20b] SQLite= 101 2010-03-12 16:17:14.378 Snap2Play[51282:20b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[NSString stringWithUTF8String:]: NULL cString'
???