Re: ARC dealloc best pratice
Re: ARC dealloc best pratice
- Subject: Re: ARC dealloc best pratice
- From: Jens Alfke <email@hidden>
- Date: Fri, 06 Feb 2015 15:27:38 -0800
> On Feb 6, 2015, at 2:00 PM, Greg Parker <email@hidden> wrote:
>
> Swift adds "unowned" references. These references are non-retaining. They differ from weak references and unsafe unretained references: unowned references fail with a runtime error if you try to access the pointed-to object after it has been deallocated.
…
> They are cheaper than weak references and safer than unsafe-unretained.
What makes them cheaper than weak references? It sounds like they both have to do the same bookkeeping to track whether the pointed-to object is alive; the only difference is the behavior when accessing the reference after the pointed-to object is dealloced (i.e. treating the pointer as nil vs. failing with an error.) Both of those seem equivalent in complexity.
But maybe I'm off-base on how weak references are implemented… I'd love to see an explanation, actually.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden