2010-12-02 86 views
3

我有這種方法,分析儀告訴我有可能泄漏的itemsArray可變數組。在方法結尾添加了相應的release,但分析儀結果仍然存在。潛在的泄漏分析儀結果不會消失

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

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

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

我該如何解決這個問題?

感謝。

回答

0

爲什麼不嘗試在[self dismissModalViewControllerAnimated:YES]之前放置[itemsArray release];

1

此代碼不會產生任何問題與分析:

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]; 
} 

你能後的確切措辭(或者截圖),你看到的警告?