此代码正在泄漏,性能工具将此代码块归咎于两个泄漏。如果我将其注释掉,则不会发生泄漏。任何将其固定下来的帮助将不胜感激。
泄漏:
Malloc 48 字节
NSCFarray 32 字节
代码块:
NSArray *myArray = [[NSArray alloc] initWithObjects: @"Add", @"Edit", nil];
segmentControl = [[UISegmentedControl alloc] initWithItems:myArray];
[myArray release];
[segmentControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentControl setMomentary:YES];
[segmentControl addTarget:self action:@selector(addOrEditPressed) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *myBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:segmentControl];
self.navigationItem.rightBarButtonItem = myBarButtonItem;
[myBarButtonItem release];