gpt4 book ai didi

iphone - 这段代码是否有可能在内存方面引起任何问题?

转载 作者:行者123 更新时间:2023-12-01 18:33:05 25 4
gpt4 key购买 nike

我想我隐藏工具栏感到紧张。我是否还需要进行其他取消分配?

 - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];


self.navigationItem.title = @"Add Recipients";

self.navigationController.toolbarHidden=NO;


UIBarButtonItem *localItem;
UIBarButtonItem *remoteItem;


localItem = [[ UIBarButtonItem alloc ] initWithTitle: @"Local"
style: UIBarButtonItemStyleBordered
target: self
action: @selector( localRecipients: ) ];



remoteItem = [[ UIBarButtonItem alloc ] initWithTitle: @"Remote"
style: UIBarButtonItemStyleBordered
target: self
action: @selector( remoteRecipients: ) ];


self.toolbarItems = [ NSArray arrayWithObjects: localItem,remoteItem,nil ];

[localItem release];
[remoteItem release];


}


- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];

self.navigationController.toolbarHidden=YES;



}

最佳答案

您不需要进行重新分配,因为您已经通过释放这两个UIBarButtonItem来保护代码中的内容。

如果您保留toolbarItems,请尝试以下代码。

self.toolbarItems = nil ;
self.toolbarItems = [ NSArray arrayWithObjects: localItem,remoteItem,nil ];

关于iphone - 这段代码是否有可能在内存方面引起任何问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5967079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com