every time connect sqlite object create , remain, here code connect db
+ (void) getinitialdatatodisplay:(nsstring *)dbpath :(nsstring *)searchtext{ mashahirappdelegate *appdelegate = (mashahirappdelegate *)[[uiapplication sharedapplication] delegate]; nsstring *cat=[[[nsstring alloc]initwithformat:@"%@%@%@",@"-",[mashahirappdelegate catid],@"-"]autorelease]; if (sqlite3_open([dbpath utf8string], &database) == sqlite_ok) { nsstring *query=[[nsstring alloc]initwithformat:@"select id, name profile name '%@%@%@%@%@",@"%",searchtext,@"%' , parentcat '%",cat,@"%' order name"]; const char *sql = [query utf8string ]; [query release]; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, null) == sqlite_ok) { while(sqlite3_step(selectstmt) == sqlite_row) { nsinteger primarykey = sqlite3_column_int(selectstmt, 0); mashahirdb *mashahirdbobj = [[mashahirdb alloc] initwithprimarykey:primarykey]; mashahirdbobj.name = [nsstring stringwithutf8string:(char *)sqlite3_column_text(selectstmt, 1)]; [appdelegate.mashahirarray addobject:mashahirdbobj]; [mashahirdbobj release]; } } sqlite3_finalize(selectstmt); } sqlite3_close(database); }
this picture instrument: picture instrument http://029.img98.net/out.php/i282779_12121.png
the picture have linked doesn't show memory leaks, allocations detail , normal see allocations.
Comments
Post a Comment