XCode 4.4 Auto @Synthesize 在 XCode 4.3 项目上失败 [英] XCode 4.4 Auto @Synthesize failing on an XCode 4.3 Project

查看:34
本文介绍了XCode 4.4 Auto @Synthesize 在 XCode 4.3 项目上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就这么简单.

奔跑的狮子.

  1. 我刚刚升级到 XCode 4.4
  2. 加载了我最近的 XCode 4.3 项目文件
  3. 注释掉一行@synthesize 代码
  4. 并且错误比比皆是.:(

已验证的编译器设置为LLVM 4.0".

Verified compiler is set to 'LLVM 4.0'.

然后我做了同样的测试,但在 XCode 4.4 中创建了一个新项目,瞧!自动@synthesize 在 4.4 项目中工作.

Then I did the same test but created a new project within XCode 4.4, and voila! Auto @synthesize works within a 4.4 project.

Auto @synthesize also 似乎适用于添加到代码中的 属性.但是现有的旧的会产生错误.

Auto @synthesize also seems to work on new properties added to the code. But existing old one generate an error.

还有其他人遇到过这种情况吗?还有什么我应该检查的吗?

Anyone else experience this? Any other things I should check for?

我真的希望自动生成功能能够正常工作.

I really want the auto generation features to work.

谢谢.

推荐答案

错误不在于您声明属性的方式,而在于您使用它的方式.

The Error isn't the way you declare the property but in the way that you use it.

自动合成的属性创建一个带有默认前导下划线的后备存储.

Auto-synthesized properties create a backing store with a leading underscore by default.

所以在您的代码中,当您将属性声明为:

So in your code when you have a property declared as:

@property (nonatomic, strong) UILabel *sectorLabel;

并且您自动合成 - 编译器会自动为您生成类似这样的内容:

and you auto-sythesize - something like this is being auto-generated for you by the compiler:

@synthesize sectorLabel = _sectorLabel;

现在您可以通过属性访问它:

Now you can access it through the the property:

self.sectorLabel;

或者,您可以直接访问后备存储:

Or, you can access the backing store directly with:

_sectorLabel;

这篇关于XCode 4.4 Auto @Synthesize 在 XCode 4.3 项目上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆