My application crashed when I retrieve second time from sqlite database in my running iPhone application -
- (void) hydratedetailviewdata { strong text//if detail view hydrated not database. if(isdetailviewhydrated) return; if(detailstmt == nil) { const char *sql = "select name,rdate,image movie_data 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 date in temporary variable. nsdate *date1; date1 = [nsdate datewithtimeintervalsince1970:sqlite3_column_double(detailstmt, 1)]; //nsinteger dateininteger = sqlite3_column_int(detailstmt, 2); //self.setdate= dateininteger; //assign date. date value copied, since property declared "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 temporary variable. since created using alloc, have own it. [date1 release]; } else nsassert1(0, @"error while getting price of coffee. '%s'", sqlite3_errmsg(database)); //detailviewcontroller.dvobj= //reset detail statement. sqlite3_reset(detailstmt); //set isdetailviewhydrated yes, not again database. isdetailviewhydrated = yes; }
second time pointer not go in if condition & directly goes in else part.
please change date binding code , use following code:
nsinteger datevalues = sqlite3_column_int(detailstmt, 1); self.date17 = (int )datevalues;
where date17
nsinteger
defined in .h file, because think date field in database integer.
Comments
Post a Comment