- (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)];
}
看看上面的代码,有人可以告诉我出了什么问题,为什么我不能把它加载到我的详细视图上?我基本上按照iphone sdk文章的教程进行了操作。但是我还有这个不知道为什么会出错。
如果你们需要看一下,我甚至可以发送我的项目。
错误消息:
*** 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]
答案 0 :(得分:1)
您的错误和您的问题不匹配,就我所见,错误与上述代码无关。
错误与调用loadViewFromNibNamed:bundle:有关 - 我猜你的项目中没有一个名为DetailView.xib的xib文件
答案 1 :(得分:0)
看起来您缺少将参数绑定到SQL select语句的语句。你有这个:
const char *sql = "select snapTitle, snapDesc from Snap where snapID =?";
但是你从来没有在我能看到的任何地方设置snapID的值。在执行查询之前,您需要这样的语句:
sqlite3_bind_int(detailStmt, 1, snapID);