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

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

    • <bdo id='tZ8mA'></bdo><ul id='tZ8mA'></ul>
    <tfoot id='tZ8mA'></tfoot>

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

    1. @property 和 @synthesize 的意义何在?

      时间:2023-10-03
      <i id='anaDl'><tr id='anaDl'><dt id='anaDl'><q id='anaDl'><span id='anaDl'><b id='anaDl'><form id='anaDl'><ins id='anaDl'></ins><ul id='anaDl'></ul><sub id='anaDl'></sub></form><legend id='anaDl'></legend><bdo id='anaDl'><pre id='anaDl'><center id='anaDl'></center></pre></bdo></b><th id='anaDl'></th></span></q></dt></tr></i><div id='anaDl'><tfoot id='anaDl'></tfoot><dl id='anaDl'><fieldset id='anaDl'></fieldset></dl></div>
        <tbody id='anaDl'></tbody>

          • <bdo id='anaDl'></bdo><ul id='anaDl'></ul>
          • <small id='anaDl'></small><noframes id='anaDl'>

          • <legend id='anaDl'><style id='anaDl'><dir id='anaDl'><q id='anaDl'></q></dir></style></legend><tfoot id='anaDl'></tfoot>

                本文介绍了@property 和 @synthesize 的意义何在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我没弄明白,也没有网站能解释得够清楚……@property@synthesize的具体用途是什么代码>?

                I haven't been able to figure it out, and there are no websites which explain it clearly enough... what exactly are the purposes of @property and @synthesize?

                提前致谢!

                推荐答案

                Objective-C 运行时编程指南:声明的属性

                @property 为要实现的公共属性声明 getter 和 setter 方法.例如这个属性声明:

                @property declares the getter and the setter methods for the public property you want to implement. For example this property declaration:

                @property float value;
                

                相当于:

                - (float)value;
                - (void)setValue:(float)newValue;
                

                @synthesize 为这两个访问器提供默认实现.

                @synthesize provides default implementation for these two accessors.

                更新:上面解释了这两者的作用.它没有解释他们的目的是什么.:-)

                Update: The above explains what these two do. It does not explain what their purpose is. :-)

                • @property 向公共接口添加一个成员,该成员充当类客户端的数据变量,但使用方法进行读取和写入.这使您可以更好地控制客户端和代码之间交换的数据,例如,您可以对代码给出的值进行扩展验证.
                • @synthesize 允许您不显式编写将由客户端调用的代码,而实际上您自己将属性视为数据变量.
                • @property adds a member to the public interface that acts as a data variable to your class clients, but is read and written using methods. This gives you better control over the data that is exchanged between the client and your code, for example you can do extended validation on the values your code is given.
                • @synthesize allows you to not explicitly write the code that will be called by the client and actually treat the property as a data variable yourself.

                这篇关于@property 和 @synthesize 的意义何在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何以编程方式删除在父类 NIB 文件中创建的选项卡栏项? 下一篇:如何通过 iPhone 应用程序单击一次按钮在 Facebook 墙上发布图像

                相关文章

                      <bdo id='mQM0L'></bdo><ul id='mQM0L'></ul>

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

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

                  2. <legend id='mQM0L'><style id='mQM0L'><dir id='mQM0L'><q id='mQM0L'></q></dir></style></legend>