1. <tfoot id='PoV41'></tfoot>
      <bdo id='PoV41'></bdo><ul id='PoV41'></ul>
    1. <small id='PoV41'></small><noframes id='PoV41'>

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

      IOS,ARC,属性:(readwrite,nonatomic)vs(radwrite,retain,nonatomic

      IOS, ARC, Property: (readwrite, nonatomic) vs (radwrite, retain, nonatomic)(IOS,ARC,属性:(readwrite,nonatomic)vs(radwrite,retain,nonatomic))
    2. <legend id='3ghI2'><style id='3ghI2'><dir id='3ghI2'><q id='3ghI2'></q></dir></style></legend>
          <tbody id='3ghI2'></tbody>

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

              <small id='3ghI2'></small><noframes id='3ghI2'>

              • <bdo id='3ghI2'></bdo><ul id='3ghI2'></ul>
              • <tfoot id='3ghI2'></tfoot>
                本文介绍了IOS,ARC,属性:(readwrite,nonatomic)vs(radwrite,retain,nonatomic)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已经阅读了一些关于 ARC 的教程,但对属性声明仍然有些困惑.我使用以下模式编写了大部分代码:

                I am have read up some tutorials on ARC and am still left a bit confused on properties declarations. I wrote most most my code using the following pattern:

                @property (readwrite, nonatomic) PlayerData* playerData;
                @property (readwrite, nonatomic) MusicLayer* musicLayer;
                @property (readwrite, nonatomic) bool isPowerUpAvailable;
                

                现在我终于开始处理内存泄漏了,XCode 建议我在一些代码中应该在属性声明中添加retain"关键字.

                Now that I finally started to deal with memory leaks XCode suggested me that in some bits of code I should have added the "retain" keyword in the property declaration.

                使用 ARC,我认为我不应该再打扰"保留计数了.是否有一些我没有得到或缺少的概念?任何教程参考或解释将不胜感激.

                Using ARC I thought I shouldn't "Bother" about retain counts anymore. Is there some concept I am not getting or missing? Any tutorial references or explanation would be greatly appreciated.

                推荐答案

                ARC会根据属性声明来保留对象,需要保留的属性使用strong对于不需要保留的属性weak.

                ARC is will retain object based on the property declaration, you should use strong for properties that need to be retained and weak for properties that do not need to be retained.

                weak 属性在对象被释放时也会被清零.

                weak properties are also nilled when the object is deallocated.

                编译器将始终假定属性为 readwrite,因此无需以这种方式声明.

                The compiler will always assume that properties are readwrite so there is no need to declare then this way.

                @property (strong, nonatomic) PlayerData* playerData;
                @property (strong, nonatomic) MusicLayer* musicLayer;
                // Need use assign since strong is for objects only.
                @property (assign, nonatomic) bool isPowerUpAvailable;
                

                这篇关于IOS,ARC,属性:(readwrite,nonatomic)vs(radwrite,retain,nonatomic)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                Copy text to clipboard with iOS(使用 iOS 将文本复制到剪贴板)
                How to copy text to clipboard/pasteboard with Swift(如何使用 Swift 将文本复制到剪贴板/粘贴板)
                How to show the progress of copying a large file in iOS?(如何在iOS中显示复制大文件的进度?)
                  <bdo id='6WQSr'></bdo><ul id='6WQSr'></ul>

                  <small id='6WQSr'></small><noframes id='6WQSr'>

                  <legend id='6WQSr'><style id='6WQSr'><dir id='6WQSr'><q id='6WQSr'></q></dir></style></legend>
                • <i id='6WQSr'><tr id='6WQSr'><dt id='6WQSr'><q id='6WQSr'><span id='6WQSr'><b id='6WQSr'><form id='6WQSr'><ins id='6WQSr'></ins><ul id='6WQSr'></ul><sub id='6WQSr'></sub></form><legend id='6WQSr'></legend><bdo id='6WQSr'><pre id='6WQSr'><center id='6WQSr'></center></pre></bdo></b><th id='6WQSr'></th></span></q></dt></tr></i><div id='6WQSr'><tfoot id='6WQSr'></tfoot><dl id='6WQSr'><fieldset id='6WQSr'></fieldset></dl></div>
                        <tbody id='6WQSr'></tbody>

                          <tfoot id='6WQSr'></tfoot>