开发者

Potential leak Analyzer result wont go away

I have this method, and the analyzer tells me there is a potential leak of the itemsArray mutable array. I have added the corresponding release at the end of the method, but still the analyzer result remains.

- (void)addCategory:(NSString*)category {
    NSMutableArray *itemsArray = [[NSMutableArray alloc] initWithCapacity:1];

    if (category) {
        [[APP_DELEGATE itemsDictionary] setObject:itemsArray forKey:category];  
    }

    [self dismissModalViewControllerAnimated:YES];
    [itemsArray release];
}

How can开发者_高级运维 i fix it?

Thanks.


This code does not raise any issues with the analyzer:

static NSMutableDictionary *itemsDictionary;

- (void)addCategory:(NSString*)category {
    NSMutableArray *itemsArray = [[NSMutableArray alloc] initWithCapacity:1];

    if (category) {
        [itemsDictionary setObject:itemsArray forKey:category];  
    }

    [self dismissModalViewControllerAnimated:YES];
    [itemsArray release];
}

Can you post the exact wording (or perhaps a screenshot) of the warning you see?


why dont you try putting [itemsArray release] before the line of [self dismissModalViewControllerAnimated:YES];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜