I have below code which is causing memory leak
-(NSString *) getSingRecord: (NSString *) getStatement{
NSString *sql=getStatement;
sqlite3_stmt *statement;
NSString *fieldFlagI=@"0";
if (sqlite3_prepare_v2(db, [sql UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *fieldFlag=(char *) sqlite3_column_text(statement, 0);
fieldFlagI=[[NSString alloc] initWithUTF8String:fieldFlag];
//fieldFlagI=[NSString initWithUTF8String:fieldFlag];
}
sqlite3_finalize(statement);
}
//NSString *ffI=fieldFlagI;
//[fieldFlagI release]
return [fieldFlagI];
}
After checking apple documentation i changed code to return [fieldFlagI autorelease];
and in the code segment where i am calling this function
NSString *getRecord=[dbase getSingRecord:flag];
if i do a [getRecord release]; - application crashes - how do i release this object?