次のコードを参照してください。これは単なる方法であり、メモリ管理の問題を理解できず、私に教えてください。次のコードで何が起きていますか?ここProduct> Analyze in XCodeを使用してオブジェクトを解放する方法
-(IBAction)selectMarina {
NSLog(@"Select Marina");
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
//[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
//[closeButton release];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
[pickerView selectRow:0 inComponent:0 animated:NO];
}
、どのように私はこのコードでは適切なメモリ管理を行うことができますし、あなたが指定することができます
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
ライン上で、このようなMSGを示しているPotential leak of object allocated on line 112 and stored into close button
を言っていますそれは詳細
ありがとう
は、なぜ私はpickerViewをリリースする予定クリック見えますか? –
それはグローバルでもローカルでもなく、それをどのように解放すると言いますか? –
私はその点を逃しています。インスタンスがグローバルに宣言されている場合は、deallocメソッドで解放する必要があります。 – iamsult