• <small id='WAXys'></small><noframes id='WAXys'>

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

      1. 使用 ARC 声明委托属性的推荐方法

        Recommended way to declare delegate properties with ARC(使用 ARC 声明委托属性的推荐方法)

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

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

                    <tbody id='HjjJP'></tbody>
                • <legend id='HjjJP'><style id='HjjJP'><dir id='HjjJP'><q id='HjjJP'></q></dir></style></legend>
                  本文介绍了使用 ARC 声明委托属性的推荐方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我曾经将所有委托属性声明为

                  I used to declare all delegate properties as

                  @property (assign) id<FooDelegate> delegate;
                  

                  我的印象是所有的赋值属性现在都应该是弱指针,这是正确的吗?如果我尝试声明为:

                  I was under the impression that all assign properties should now be weak pointers, is this correct? If I try to declare as:

                  @property (weak) id<FooDelegate> delegate;
                  

                  尝试@synthesize 时出现错误(不支持自动生成的弱属性).

                  I get an error while trying to @synthesize (autogenerated weak properties are not supported).

                  在这种情况下,最佳做法是什么?

                  What's the best practice in this case?

                  推荐答案

                  对于面向 iOS 4 和 5 的 ARC 项目,使用 __unsafe_unretained 而不是 weak.唯一的区别是 weak 释放时指针为零,仅在 iOS 5 中支持.

                  Use __unsafe_unretained instead weak for ARC projects targeting iOS 4 and 5. The only difference is that weak nils the pointer when deallocated, and it's only supported in iOS 5.

                  为什么 Objective-C 委托通常被赋予属性 assign 而不是保留?.

                  这篇关于使用 ARC 声明委托属性的推荐方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Objective c - Best practice to handle a button touch event for a button of a custom UITableViewCell(Objective c - 为自定义 UITableViewCell 的按钮处理按钮触摸事件的最佳实践)
                  UIButton targets not working if a UIView is added as a subview(如果将 UIView 添加为子视图,则 UIButton 目标不起作用)
                  Tint UIButton#39;s image from interface builder with UIImageRenderingModeAlwaysTemplate(使用 UIImageRenderingModeAlwaysTemplate 从界面生成器中为 UIButton 的图像着色)
                  What#39;s the difference between UIControlStateHighlighted and UIControlStateSelected?(UIControlStateHighlighted 和 UIControlStateSelected 有什么区别?)
                  Bring UIButton to front layer(将 UIButton 带到顶层)
                  Custom buttons in XIB used as Custom UITableViewCell don#39;t respond to taps (ios7)(用作自定义 UITableViewCell 的 XIB 中的自定义按钮不响应点击(ios7))

                  <small id='0Xop2'></small><noframes id='0Xop2'>

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

                        <bdo id='0Xop2'></bdo><ul id='0Xop2'></ul>
                        <legend id='0Xop2'><style id='0Xop2'><dir id='0Xop2'><q id='0Xop2'></q></dir></style></legend>

                          <tbody id='0Xop2'></tbody>

                          • <tfoot id='0Xop2'></tfoot>