object not getting released in iphone

Posted by Jaimin on Stack Overflow See other posts from Stack Overflow or by Jaimin
Published on 2010-05-28T07:43:25Z Indexed on 2010/05/28 7:51 UTC
Read the original article Hit count: 200

Filed under:
|

i m writing this code in my code to store the data in database..

Search *objSearchDetail = [[Search alloc] init];

        objSearchDetail = [xmlResponseDetail objectAtIndex:i];

        sql = "INSERT INTO tblsearchdetail(tblrecentsearch_id,name,address,email,url,street,postcode,city,telephone,mobile) VALUES(?,?,?,?,?,?,?,?,?,?)";
        returnValue = sqlite3_prepare_v2(database, sql, -1, &insertStatement, NULL);

        if(returnValue == SQLITE_OK){
            sqlite3_bind_int(insertStatement, 1, intLastRecentSearchId);
            sqlite3_bind_text(insertStatement, 2, [objSearchDetail.strName UTF8String], -1,SQLITE_TRANSIENT);   
            sqlite3_bind_text(insertStatement, 3, [objSearchDetail.strAddress UTF8String], -1,SQLITE_TRANSIENT);    
            sqlite3_bind_text(insertStatement, 4, [objSearchDetail.strEmail UTF8String], -1,SQLITE_TRANSIENT);  
            sqlite3_bind_text(insertStatement, 5, [objSearchDetail.strUrl UTF8String], -1,SQLITE_TRANSIENT);    
            sqlite3_bind_text(insertStatement, 6, [objSearchDetail.strStreet UTF8String], -1,SQLITE_TRANSIENT); 
            sqlite3_bind_text(insertStatement, 7, [objSearchDetail.strPostCode UTF8String], -1,SQLITE_TRANSIENT);
            sqlite3_bind_text(insertStatement, 8, [objSearchDetail.strPlace UTF8String], -1,SQLITE_TRANSIENT);
            sqlite3_bind_text(insertStatement, 9, [objSearchDetail.strTelephone UTF8String], -1,SQLITE_TRANSIENT);
            sqlite3_bind_text(insertStatement, 10, [objSearchDetail.strMobile UTF8String], -1,SQLITE_TRANSIENT);
            if(sqlite3_step(insertStatement)==SQLITE_DONE)
            {
                //Data;                 
            }
        }
        NSLog(@"count %d",[objSearchDetail retainCount]);
        [objSearchDetail release];

now the nslog shows refrence count as 2 so even if i release the refrence count will still be one and the object will not be destroyed.. plz help me....

© Stack Overflow or respective owner

object not getting released in iphone

Posted by mohsinpathan on Stack Overflow See other posts from Stack Overflow or by mohsinpathan
Published on 2010-05-28T09:38:18Z Indexed on 2010/05/28 9:41 UTC
Read the original article Hit count: 200

Filed under:
NSString *strSql = @"select tblrecentsearch_id,xmlrequest,company,postcode,city,kilometer,date from tblrecentsearch";

returnValue = sqlite3_prepare_v2(database, [strSql UTF8String], -1, &selectStatement, NULL); if(returnValue == SQLITE_OK) { arrRecentSearch=[[NSMutableArray alloc] init];

while(sqlite3_step(selectStatement)==SQLITE_ROW) { Search *ObjSearch = [[Search alloc]init]; ObjSearch.intRecentSearchId = sqlite3_column_int(selectStatement, 0); ObjSearch.xmlRequest = [NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 1) encoding:NSUTF8StringEncoding]; ObjSearch.strCompnay=[NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 2) encoding:NSUTF8StringEncoding]; ObjSearch.strPostCode=[NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 3) encoding:NSUTF8StringEncoding]; ObjSearch.strPlace = [NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 4) encoding:NSUTF8StringEncoding]; ObjSearch.strKilometer = [NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 5) encoding:NSUTF8StringEncoding]; ObjSearch.strDate = [NSString stringWithCString:(char *)sqlite3_column_text_check(selectStatement, 6) encoding:NSUTF8StringEncoding];

[arrRecentSearch addObject:ObjSearch];

[ObjSearch release]; } }

sqlite3_finalize(selectStatement);

I want release arrRecentSearch but it will return from function . How can i realese this array. Please help me.I am fetching data from databse.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-leaks