- (void) hydrateDetailViewData {
//if detail view is hydrated then do not get it from database
if(isDetailVie开发者_高级运维wHydrated) 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 (sqlite3_step(detailStmt) == SQLITE_ROW)//execute sql statement on database, and make sure it executed properly.
{
self.snapDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 1)];
}
looking at the above code, can someone tell me what's wrong and why is it that i can't get it to load on my detailview?i basically followed the tutorial on iphone sdk article..but yet i am having this don't know why error.
i can even send my project if u guys need to take a look.
Error msg:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] was unable to load a nib named "DetailView"'
2010-03-15 16:35:55.202 Snap2Play[58213:20b]
Your error and your problem don't match, the error is nothing to do with the above code as far as I can see.
The error is to do with a call to loadViewFromNibNamed:bundle: - I'm guessing that you don't have a xib file in your project called DetailView.xib
It looks like you are missing a statement to bind a parameter to your SQL select statement. You have this:
const char *sql = "select snapTitle, snapDesc from Snap where snapID =?";
but you never set the value for snapID anywhere that I can see. You need a statement like this before you execute the query:
sqlite3_bind_int(detailStmt, 1, snapID);
精彩评论