释放一个navigationItem
我有以下问题:
我有一个 AppDelegate,我在其中添加一个 navigationController 并在其中加载 UIViewController B。
在 BI 中添加一个 navigationItem、一个 leftBarButtonItem 或一个 rightBarButtonItem。
我必须在哪里释放这些项目,因为我在 B 中分配并初始化它们。所以一开始我考虑在 B 的 Dealloc-Method 中释放 self.navigationItem.rightBarButtonItem。
但是如果我正在分析我的应用程序,分析器会说在 B 的 dealloc 方法中的释放位置:
不正确的对象引用计数递减 此时由调用者拥有。
但我不明白我做错了什么,还是一切正常,这是分析仪问题?
有人可以帮我查一下吗?
问候安迪1984
I've the following question:
I've an AppDelegate and I add there a navigationController and load UIViewController B in it.
In B I add a navigationItem, a leftBarButtonItem or a rightBarButtonItem.
Where do I have to release these items, because I alloc and init them in B. So at the first I thought about releasing self.navigationItem.rightBarButtonItem in Dealloc-Method of B.
But if I'm analyzing my app, the analyzer says at the release-position in B's dealloc-method:
Incorrect decrement of the reference count of an object that is not
owned at this point by the caller.
But I don't understad what I've done wrong or is everything ok and it's an analyzer problem?
Can somebody help me finding out?
Greets andi1984
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦分配并分配给 rightBarButtonItem,您就可以像
leftBartButtonItem 一样
释放self.navigationItem.rightBarButtonItem 本身可能有一个保留,并且知道何时释放该计数。
As soon as you allocate and assign to rightBarButtonItem you can release like
Similarly to leftBartButtonItem
self.navigationItem.rightBarButtonItem might have a retain in itself and knows when to release that count.