Re: ARC refactor misses IBOutlets?
Re: ARC refactor misses IBOutlets?
- Subject: Re: ARC refactor misses IBOutlets?
- From: David Duncan <email@hidden>
- Date: Sat, 27 Oct 2012 09:50:23 -0700
On Oct 27, 2012, at 1:28 AM, Rick Mann <email@hidden> wrote:
> I'm using the convert-to-ARC refactor tool to update an older project. It seems to have gone okay, but it has made all my IBOutlet properties that were retain into strong, instead of making them weak, which is what I thought one was supposed to do.
Both strong and weak are acceptable for IBOutlets. However without knowing what patterns you are implementing, strong is the safer assumption (for example if you swap some views in and out of your view hierarchy, weak is wrong).
> Have I been wrong all this time making my IBOutlets retain instead of assign? I always set them to nil in -viewDidUnload, released them in -dealloc.
Nope, and outside of ARC retain/strong is the only safe way to reference views via properties. That said, while evaluating behaviors in UIViewControllers in iOS 6 it was determined that it was not very useful to actually release your views in -viewDidUnload (or generally do any of the view related work that is typically done in -viewDidUnload). As such as of iOS 6 it is no longer called, and the recommendation is to not bother implement it for iOS 5 onwards.
As such on iOS 6 or later, both strong & weak have effectively the same behavior unless you set the view controller's view to nil yourself, or you remove the views from their superview (which as a pattern is probably wrong to do with a view referenced only weakly).
--
David Duncan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden