NSString memory leak [closed]
//opening DB
if(sqlite3_step(statement) == SQLITE_ROW)
result = [NSString stringWithUTF8String:(char*)sqlite3_column_text(statement,0)]; //!
else
result nil;
return result;
//close DB
This is actually not a memory leak. The NSString will be autoreleased, and the char*
returned by sqlite3_column_text
will be cleaned up by sqlite during the next step/reset/finalize call.
the string should be autoreleased by stringWithUTF8String, are you testing for memory leaks on the iPhone or on the simulator? Often the simulator code is just a touch buggier - try it on the device itself
精彩评论