Re: Understanding ARC
Re: Understanding ARC
- Subject: Re: Understanding ARC
- From: Charles Srstka <email@hidden>
- Date: Sun, 25 May 2014 12:19:06 -0500
On May 25, 2014, at 11:38 AM, Jens Alfke <email@hidden> wrote:
> On May 24, 2014, at 11:34 PM, Charles Srstka <email@hidden> wrote:
>
>> This isn't strictly true; when you are returning objects by reference, doing so inside the @autoreleasepool will cause a crash. For example:
>
> That’s a different scenario than the one the OP was asking about; stuffing a reference into the address pointed to by a parameter is not the same thing as returning a value. (If only Obj-C had proper support for multiple return values. That’s one of my favorite features of Go.)
>
> I agree it’s sort of related, but let’s not overcomplicate things. We are trying to help a newbie, not write a textbook that has to cover every possible case.
I disagree; this scenario is pretty important to keep in mind, since any app of appreciable size is going to need to worry about error reporting, the Cocoa standard for doing so is to return an autoreleasing NSError by reference, and this sort of thing is *really* easy to get bitten by, and then not realize it for a long time afterwards.
Charles
_______________________________________________
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