释放appDelegate实例?

发布于 2024-12-03 19:51:41 字数 558 浏览 4 评论 0原文

可能的重复:
我应该何时释放 [[UIApplication sharedApplication] delegate] 对象?

我在我的应用程序中多次创建 UIApplication 实例来访问共享信息,如下所示:

MyAppDelegate *appDelegate =  (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.ListingNav.navigationBarHidden = FALSE;

那么,它应该如何释放所有这些 appDelegate 对象?它们不会造成累积的内存泄漏吗?

感谢您的帮助,

斯蒂芬

Possible Duplicate:
When should I release [[UIApplication sharedApplication] delegate] object?

I'm creating instances of UIApplication many times in my app to access shared infos, like this:

MyAppDelegate *appDelegate =  (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.ListingNav.navigationBarHidden = FALSE;

Well, how should it release all these appDelegate objects? Won't they create accumulated memory leaks ?

Thx for helping,

Stephane

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掐死时间 2024-12-10 19:51:41

一般来说,如果你不调用allocretain,那么你就不需要调用release。在此用例中,您不需要释放 appDelegate

In general, if you do not call alloc or retain, then you do not need to call release. You do not need to release appDelegate in this use case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文