释放appDelegate实例?
可能的重复:
我应该何时释放 [[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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,如果你不调用
alloc
或retain
,那么你就不需要调用release
。在此用例中,您不需要释放appDelegate
。In general, if you do not call
alloc
orretain
, then you do not need to callrelease
. You do not need to releaseappDelegate
in this use case.