0
我已將我的XCode升級到版本3.2.3,以在我的iPhone項目上支持iOS4。我使用靜態分析器檢查內存管理問題。不懂內存分析
在我的一個例程中,我得到以下問題: 我在向日歷添加事件以生成狀態後生成用戶警報。
這運行良好,但內存分析器不喜歡我如何定義警報。 我看不到編碼問題,是嗎? (我指定的內存分析提示與 「< < < <」)
- (IBAction) addToCalendar {
...
UIAlertView *tmpAlert = [UIAlertView alloc]; <<<<Method returns an Objective-C object with a+1 retain count (owning reference)
calData.startDate = iVar.zeitVon;
calData.endDate = iEvent.zeitBis;
calData.title = iVar.title;
calData.calendar = myEventStore.defaultCalendarForNewEvents;
if ([tmpEventStore saveEvent:tmpEvent span:EKSpanThisEvent error:&tmpSaveError]) {
// Show a save success dialog
[tmpAlert initWithTitle:@"Success" <<<<Object released
message:@"entry saved" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
} else {
// Show a save error dialog
[tmpAlert initWithTitle:@"Error"
message:@"entry not saved" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] ;
}
[tmpAlert show]; <<<<Reference counted object is used after its released
[tmpAlert release];
}
感謝
是的,我現在改變了例程以使2 2gether(alloc&init)和警告消失,謝謝你:) – iFloh 2010-07-14 05:07:16
請向LLVM靜態分析器團隊提交一個錯誤報告(關於不要警告decoupled alloc init) :http://clang-analyzer.llvm.org/filing_bugs.html併爲社區做一件事! – Yuji 2010-07-14 05:13:41