iPhone プロジェクトで iOS4 をサポートするために、XCode をバージョン 3.2.3 にアップグレードしました。静的アナライザーを使用して、メモリ管理の問題をチェックしました。
私のルーチンの 1 つで、次の問題が発生します。イベントをカレンダーに追加してステータスを表示した後、ユーザー アラートを生成します。
これは正常に実行されますが、メモリ アナライザーはアラートの定義方法を気に入りません。コーディングの問題がわかりませんね。(メモリアナライザーのヒントを「<<<<」で示しました)
- (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];
}
ありがとう