<small id='Ea8tO'></small><noframes id='Ea8tO'>

    • <bdo id='Ea8tO'></bdo><ul id='Ea8tO'></ul>

    <tfoot id='Ea8tO'></tfoot>

    <legend id='Ea8tO'><style id='Ea8tO'><dir id='Ea8tO'><q id='Ea8tO'></q></dir></style></legend>

      <i id='Ea8tO'><tr id='Ea8tO'><dt id='Ea8tO'><q id='Ea8tO'><span id='Ea8tO'><b id='Ea8tO'><form id='Ea8tO'><ins id='Ea8tO'></ins><ul id='Ea8tO'></ul><sub id='Ea8tO'></sub></form><legend id='Ea8tO'></legend><bdo id='Ea8tO'><pre id='Ea8tO'><center id='Ea8tO'></center></pre></bdo></b><th id='Ea8tO'></th></span></q></dt></tr></i><div id='Ea8tO'><tfoot id='Ea8tO'></tfoot><dl id='Ea8tO'><fieldset id='Ea8tO'></fieldset></dl></div>

        我应该何时释放 [[UIApplication sharedApplication] delegate] 对象?

        When should I release [[UIApplication sharedApplication] delegate] object?(我应该何时释放 [[UIApplication sharedApplication] delegate] 对象?)

      1. <small id='9UH8s'></small><noframes id='9UH8s'>

          <legend id='9UH8s'><style id='9UH8s'><dir id='9UH8s'><q id='9UH8s'></q></dir></style></legend>

          <i id='9UH8s'><tr id='9UH8s'><dt id='9UH8s'><q id='9UH8s'><span id='9UH8s'><b id='9UH8s'><form id='9UH8s'><ins id='9UH8s'></ins><ul id='9UH8s'></ul><sub id='9UH8s'></sub></form><legend id='9UH8s'></legend><bdo id='9UH8s'><pre id='9UH8s'><center id='9UH8s'></center></pre></bdo></b><th id='9UH8s'></th></span></q></dt></tr></i><div id='9UH8s'><tfoot id='9UH8s'></tfoot><dl id='9UH8s'><fieldset id='9UH8s'></fieldset></dl></div>
          1. <tfoot id='9UH8s'></tfoot>
              <tbody id='9UH8s'></tbody>

              • <bdo id='9UH8s'></bdo><ul id='9UH8s'></ul>

                  本文介绍了我应该何时释放 [[UIApplication sharedApplication] delegate] 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的应用程序中多次使用以下代码(尤其是用于管理 NavigationController):

                  I'm using the following code many times in my app (especially to manage a NavigationController):

                  MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 
                  

                  我应该什么时候发布它?

                  When should I release it ?

                  感谢您的帮助,

                  斯蒂芬

                  推荐答案

                  不要.从不释放您的应用程序委托 - 它由操作系统自动管理.

                  Don't. Never release your application delegate - it is managed automatically by the OS.

                  如果您查看应用程序的 main.m 文件,您会看到一些代码初始化了代表您的应用程序的 UIApplication 实例 - 它负责管理应用程序委托的生命周期,而不是你的责任.

                  If you look in your app's main.m file, you'll see some code that initializes an instance of UIApplication that represents your app - it is its responsibility to manage the application delegate's lifecycle, not your responsibility.

                  EDIT 正如@Goz 指出的那样,如果您在某个时候 retain 它,则应该 release 它.然而,由于应用程序对象(以及因此,它的委托)保证在应用程序的生命周期内保持在范围内(除非你去搞砸它),最好简单地 对委托进行任何内存管理,因为这样可以避免意外过度释放或其他相关问题的可能性.

                  EDIT as @Goz points out, you should release it if at some point you retain it. However, since the application object (and therefore, by extension its delegate) is guaranteed to remain in scope for the life of the app (unless you go messing with it), it's far better to simply not do any memory management on the delegate, as this avoids the possibility of accidental over-release or other related issues.

                  这篇关于我应该何时释放 [[UIApplication sharedApplication] delegate] 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                  Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                  ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                  How to get indexPath.row of tableView which is currently being displayed?(如何获取当前正在显示的 tableView 的 indexPath.row?)
                  Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                  MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                  • <bdo id='e8HX1'></bdo><ul id='e8HX1'></ul>
                        <i id='e8HX1'><tr id='e8HX1'><dt id='e8HX1'><q id='e8HX1'><span id='e8HX1'><b id='e8HX1'><form id='e8HX1'><ins id='e8HX1'></ins><ul id='e8HX1'></ul><sub id='e8HX1'></sub></form><legend id='e8HX1'></legend><bdo id='e8HX1'><pre id='e8HX1'><center id='e8HX1'></center></pre></bdo></b><th id='e8HX1'></th></span></q></dt></tr></i><div id='e8HX1'><tfoot id='e8HX1'></tfoot><dl id='e8HX1'><fieldset id='e8HX1'></fieldset></dl></div>

                          <tbody id='e8HX1'></tbody>

                          <small id='e8HX1'></small><noframes id='e8HX1'>

                          <tfoot id='e8HX1'></tfoot>
                        1. <legend id='e8HX1'><style id='e8HX1'><dir id='e8HX1'><q id='e8HX1'></q></dir></style></legend>