开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜