1

I use:

@property(nonatomic, weak) IBOutlet UIView *videoView;

there is a warning:

Property 'videoView' requires method 'videoView' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation

Then I try:

@synthesize videoView;

there is an error:

The current deployment target does not support automated __weak references.

And another question:

@property(nonatomic, unsafe_unretained) IBOutlet UIView *videoView;

- (void)dealloc {
    videoView = nil;
}

Can I use this way?

Hristo Iliev
  • 72,659
  • 12
  • 135
  • 186
Aevit
  • 21
  • 5

2 Answers2

3

The current deployment target does not support automated __weak references.

The issue is that iOS 4.x doesn't support auto-zeroing weak references. This means that, when a weakly-referenced object is destroyed, the weak references continue to point to it and may cause crashes if used.

Auto-zeroing weak references are supported in iOS 5 and newer. To take advantage of them and clear the warning above, raise your minimum iOS target to 5.0, and use the 5.0 SDK.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
1

What is your deployment target? you need to have at least iOS4 to have weak references, and you need to be using LLVM4 with Xcode4.4 or later to be able to just declare your @property variables and not have to provide an @synthesize.

As for the second question - what is it that you are trying to do. If you are just trying to safely set the variable to nil on dealloc, then it is okay, since you are declaring it as unsafe_unretained you don't own it so you shouldn't release it.

Abizern
  • 146,289
  • 39
  • 203
  • 257
  • My XCode is 4.3.2, deployment target is 4.3, and my llvm is 3.1. I have a question that should I set every IBoutlet to nil? Thank you for your reply. – Aevit Aug 09 '12 at 12:54
  • Most people say it's a matter of style. I like to do it in case some other object calls it after it's controller is released so it doesn't crash. Others will tell you that calling an IBOutlet after the controller is released is a programmer error and so you want it to crash so you can fix the problem. – Abizern Aug 09 '12 at 13:00