简体   繁体   中英

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.

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.

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?

Thanks in advance.

I bet your target is 4.x right? In that case you can't use weak and so it uses 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.

You probably switched off the ARC on your project/target settings. Switch to Yes and you'll get back the Storage field.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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