views:

173

answers:

2
- (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 (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..need help urgently because i have been at this for days!!it's driving me crazy! i can even send my project if u guys need to take a look..help please!!

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]

Need some kind soul to help me debug the error..please contact me at [email protected] think it's kinda impossible to tell where the problems is because i may not know what went wrong either..help help!

A: 

Hi,

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

deanWombourne
i do have the xib with the correct filename..i need help seriously..i do not know where i had gone wrong..
summer
What is the stack trace in the debugger when your code crashes? If you put that into your question more people might be able to help?
deanWombourne
Also, if you put a link to the article in the question I can try to reproduce it on my machine and see what might be wrong?
deanWombourne
http://www.iphonesdkarticles.com/2008/10/sqlite-tutorial-loading-data-as.html i follow the tutorial..but instead of getting int i am getting character instead..
summer
A: 

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);
kharrison