Leaked NSString, not sure why is doing it?
// Allocate a product
Product *color = [[Product alloc]init];
// The result set
char *name = (char *)sqlite3_column_text(statement, 1);
NSString *nameStr = [[NSString alloc]initWithUTF8String:name];
char *code = (char *)sqlite3_column_text(statement, 2);
NSString *codeStr = [[NSS开发者_如何学编程tring alloc]initWithUTF8String:code];
color.name = nameStr;
color.code = codeStr;
// Release
[nameStr release];
[codeStr release];
[myProducts addObject:color];
[color release];
The profiler shows the leak on each of the lines I'm allocating the string. Not sure what's causing the issue as I'm releasing.
EDIT: Found the problem. I needed to release the strings on my Product object. Can't believe I missed that...
The Data Model wasn't releasing on dealloc.
精彩评论