views:

50

answers:

1

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....

+2  A: 

since you are getting the value for objSearchDetail from an array, you should neither allocate it, nor release it. Just do:

Search *objSearchDetail = [xmlResponseDetail objectAtIndex:i];

and remove

[objSearchDetail release];
unbeli