Search code examples
objective-cautomatic-ref-countingreference-counting

Using ARC on iOS 4, do I need to nil my IBOutlet properties when using unsafe_unretained instead of weak?


When using ARC with iOS 5, a weak IBOutlet creates a zeroing reference, avoiding the need to

self.< IBOutlet property > = nil;

in -(void)viewDidUnload

If I'm using iOS 4 (and using ARC) and forced to use unsafe_unretained instead, does it mean I have to override viewDidUnload and set the property to nil manually?

EDIT: This relates to my case: Should IBOutlets be strong or weak under ARC? The exception being: I can't use the 'weak' keyword which creates the zeroing reference.

Hope my question is clearer.

Thanks


Solution

  • When using ARC, as I am sure you have realized, the weak attribute cannot be used pre-iOS5. The other side of that coin would be to use unsafe_unretained. Weak attributes will automatically set your properties to nil. Unsafe_retained (aka "assign" in pre-iOS 5), will not, and you need to do this yourself.