Xcode的「構建和分析」有多可靠?XCode的構建和分析 - 錯誤或正確發現潛在的泄漏?
我一直在尋找它發現的「潛在的泄漏」 - 但不明白它。
下面的代碼:
-(void)viewDidLoad{
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *aBI = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(add:)];
self.navigationItem.rightBarButtonItem = aBI;
aBI.release;
UIBarButtonItem *eB = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self action:@selector(EinstellungenTapped:)];
UIBarButtonItem * space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *emailB = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self action:@selector(emailTapped:)];
NSArray* toolbarItems = [NSArray arrayWithObjects: eB,space,emailB,
nil];
[self setToolbarItems: toolbarItems];
eB.release; // <------- Potential leak ??????
emailB.release; // <------- Potential leak ??????
space.release; // <------- Potential leak ??????
}
爲什麼要這三個是潛在的泄漏?
即使沒有assignemt到NSArray的它告訴我泄漏。
這裏有什麼問題?
許多感謝....
爲了使它「更糟糕」...這是一種解決方法,以便警告不再出現 - 但是 - 我認爲它仍然泄漏: 只需添加賦值:self.navigationItem.rightBarButtonItem = eB; =>沒有警告了。 – user387184 2010-07-09 13:19:38