- (void) hydrateDetailViewData {
strong text//If the detail view is hydrated then do not get it from the database.
if(isDetailViewHydrated) return;
if(detailStmt == nil) {
const char *sql = "Select name,Rdate,image from Movie_data Where id = ?";
if(sqlite3_prepare_v2(database, sql, -1, &detailStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating detail view statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_int(detailStmt, 1, informationId);
if(SQLITE_DONE != sqlite3_step(detailStmt)) {
NSString *str = [NSString stringWithUTF8String:(char *)sqlite3_column_text(detailStmt, 0)];
self.informationName = str;
//Get the date in a temporary variable.
NSDate *date1;
date1 = [NSDate dateWithTimeIntervalSince1970:sqlite3_column_double(detailStmt, 1)];
//NSInteger dateInInteger = sqlite3_column_int(detailStmt, 2);
//self.setDate= dateInInteger;
//Assign the date. The date value will be copied, since the property is declared with "copy" attribute.
self.date = date1;
NSData *data =[[NSData alloc] initWithBytes:sqlite3_column_blob(detailStmt, 2) length:sqlite3_column_bytes(detailStmt, 2)];
if(data == nil)
NSLog(@"No image found.");
else
self.img = [UIImage imageWithData:data];
//Release the temporary variable. Since we created it using alloc, we have own it.
[date1 release];
}
else
NSAssert1(0, @"Error while getting the price of coffee. '%s'", sqlite3_errmsg(database));
//DetailViewController.dvObj=
//Reset the detail statement.
sqlite3_reset(detailStmt);
//Set isDetailViewHydrated as YES, so we do not get it again from the database.
isDetailViewHydrated = YES;
}
第二次指針不進去,如果條件&在其他部分直接進入檢索SQLite數據庫第二次我的應用程序崩潰。當我在運行iPhone應用程序
謝謝主席先生,您的回覆.... – AJPatel 2010-11-22 05:08:26
@AJPatel:是那答案? – JeremyP 2010-11-22 08:51:14
沒有朋友他們是錯誤在我的數據從int到日期這是我的應用程序gona崩潰 – AJPatel 2010-11-23 06:41:34