Re: Does setFormatter() retain?
Re: Does setFormatter() retain?
- Subject: Re: Does setFormatter() retain?
- From: Andreas Falkenhahn <email@hidden>
- Date: Wed, 24 Aug 2016 22:24:30 +0200
On 24.08.2016 at 22:14 Ben Kennedy wrote:
>> On 24 Aug 2016, at 1:04 pm, Andreas Falkenhahn <email@hidden> wrote:
>> I have read Apple's memory management guide on retain/release and
>> I think I've basically got it, but there's just one thing that
>> I'm not confident about and that is "setXXX" methods which accept an
>> NSObject parameter and I don't know how I can know whether the
>> "setXXX" retains or not.
> Why do you think you need to know?
If it retains, I could just do the following:
[textField setFormatter:formatter];
[formatter release];
And I wouldn't have to worry about "formatter" any longer. If it doesn't retain,
the above isn't possible.
Another example: "addSubview" retains, so I can just do:
[[win contentView] addSubview:button];
[button release];
And I'm done with "button." That's much more convenient than having to
keep "button" for much longer...
>
> That's the concern of the API
> you're calling. If it needs to retain the object you're passing it,
> then it will. If it doesn't, it won't.
I still think I should know this so that I know when I should say
"release" (see above)
> The legacy delegate stuff that you cited calls out the fact that
> they don't because it is contrary to normal expectations, and thus
> requires explicit concern by the caller.
So are you saying that the standard for setXXX methods is retain?
And if a setXXX method doesn't retain, then it's explicitly mentioned
in the doc?
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
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