添加的UINavigationController按钮是否需要自动释放?这段代码好吗?
背景 - 在我开始触发“内存警告”后,我看到应用程序中出现了一系列导航问题。我想知道这是否与我在这里提出的问题有关。问题包括:
以下代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAction:)] autorelease]; // IS AUTORELEASE HERE CORRECT?
self.navigationItem.leftBarButtonItem = self.editButtonItem;
self.title = @"Views";
感谢
答案 0 :(得分:3)
我总是只使用autorelease,我认为它应该做得很好。
答案 1 :(得分:-1)
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAction:)]; // IS AUTORELEASE HERE CORRECT?
self.navigationItem.rightBarButtonItem = rightBarButton;
[rightBarButton release];
self.navigationItem.leftBarButtonItem = self.editButtonItem;
self.title = @"Views";
}