为什么在@interface中声明对象在Xcode 4中使用@property时

编程入门 行业动态 更新时间:2024-10-26 03:22:36
本文介绍了为什么在@interface中声明对象在Xcode 4中使用@property时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 @interface first : <NSObject> { NSString *myStr; /** I don't understand why declared this NSString *myStr. Even if not declare NSString *myStr, this codes work well. **/ } @property (nonatomic, retain) NSString *myStr; and Add @synthesize to first.m

如果我始终使用myStr属性,即self.myStr,是否不需要将myStr声明为实例变量是否正确?

Is it correct that I don't need to declare myStr as an instance variable if I always use the myStr property, i.e. self.myStr?

推荐答案

在现代运行时(带有合理版本的xcode,模拟器等)中,这没有什么区别,因为编译器会为您生成它.

In the modern runtime (with a reasonably recent version of xcode, simulator etc.) it makes no difference because the compiler generates it for you.

请注意,使用最新版本的LLVM,您甚至不需要合成;)

Note that with the newest version of LLVM you don't even need the synthesize ;)

更多推荐

为什么在@interface中声明对象在Xcode 4中使用@property时

本文发布于:2023-06-07 10:09:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576139.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   声明   interface   Xcode   property

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!