简体   繁体   English

接口构建器不再为IBOutlets生成ARC兼容代码

[英]Interface builder no longer generate ARC compliant code for IBOutlets

I'm implementing my first iOS 5.1 application using XCode 4.3.2 and I'm experimenting a strange XCode interface builder behavior. 我正在使用XCode 4.3.2实现我的第一个iOS 5.1应用程序,并且正在尝试一种奇怪的XCode接口构建器行为。

I created a ViewController with NIB file in the interface builder and when connecting any UI object to the ViewController .h in order to create the IBOutlet properties, the dialog windows to set the outlet properties doesn't show the Storage field. 我在界面生成器中使用NIB文件创建了一个ViewController,并且在将任何UI对象连接到ViewController .h以便创建IBOutlet属性时,用于设置插座属性的对话框窗口都不会显示“存储”字段。

To be clear, the interface builder show this dialog: 为了清楚起见,界面构建器显示以下对话框:

屏幕截图1

instead of this one: 而不是这个:

屏幕截图2

Consequently, the code generated by the interface builder is like the following: 因此,接口构建器生成的代码如下所示:

@property (unsafe_unretained, nonatomic) IBOutlet UILabel *labelName;

while the code I'm expecting is: 而我期望的代码是:

@property (weak, nonatomic) IBOutlet UILabel *labelName;

This behavior starts to occurs from a couple of days and just for one project, so my suspicious is that I accidentally changed some project setting. 这种行为从几天开始就只针对一个项目而发生,所以我怀疑我不小心更改了某些项目设置。

Any help to restore the XCode Interface Builder behaviour in order to generate ARC code? 是否有任何还原XCode Interface Builder行为以生成ARC代码的帮助?

Thanks in advance. 提前致谢。

I bet your target is 4.x right? 我敢打赌,您的目标是4.x,对吗? In that case you can't use weak and so it uses unsafe_unretained. 在那种情况下,您不能使用弱函数,因此它使用unsafe_unretained。 They're the same thing except unsafe_unretained does not automatically nil the pointer for you but that doesn't particularly matter for your use case. 它们是同一件事,只是unsafe_unretained不会自动为您设置指针,但是这对您的用例而言并不重要。

You probably switched off the ARC on your project/target settings. 您可能在项目/目标设置上关闭了ARC Switch to Yes and you'll get back the Storage field. 切换到“ Yes ,您将返回“ Storage字段。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM