gpt4 book ai didi

iPhone 开发 - @synthesize 关键字?

转载 作者:行者123 更新时间:2023-12-03 20:26:53 25 4
gpt4 key购买 nike

我正在学习 iPhone 开发。在书中的示例中,属性提到了@synthesize关键字。

对于控件,我在 .h 文件中定义属性,但不在 .m 文件中定义 @synthesize。我正在使用 .text 属性访问文本框的属性。另外,我还链接了文本框的导出,并且文本框的名称与属性名称不同。

代码运行良好;那么不需要@synthesize关键字吗?什么时候?

最佳答案

来自 Apple 文档 > Mac 开发中心 > Cocoa 核心能力 > 声明的属性:

In addition to declaring the accessor methods, you can instruct the compiler to synthesize implementations of them (or inform the compiler that your class will synthesize them at runtime).

You use the @synthesize statement in a class’s implementation block to tell the compiler to create implementations that match the specification you gave in the property declaration.

供引用:

You use the @dynamic statement to tell the compiler to suppress a warning if it can’t find an implementation of accessor methods specified by an @property declaration.

关于iPhone 开发 - @synthesize 关键字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1866263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com