Re: Does setFormatter() retain?
Re: Does setFormatter() retain?
- Subject: Re: Does setFormatter() retain?
- From: Dave <email@hidden>
- Date: Fri, 02 Sep 2016 13:32:16 +0100
> On 29 Aug 2016, at 03:26, Andy Lee <email@hidden> wrote:
>
> On Aug 24, 2016, at 4:25 PM, Jens Alfke <email@hidden> wrote:
>>
>>> On Aug 24, 2016, at 1:04 PM, Andreas Falkenhahn <email@hidden> wrote:
>>>
>>> Now, will "setFormatter" call retain on "formatter" or not? Looking
>>> at "retainCount" seems to suggest so, although I know that this
>>> isn't reliable and shouldn't be done at all...
>>
>> These days, with ARC, we call those “strong references” vs. “weak” or “unretained” references.
>
> It used to be that when someone mentioned looking at retainCount there would a flurry of admonitions not to do that. This thread doesn't feel complete without such an admonition, so I'll refer you to this.
>
> :)
>
> <https://developer.apple.com/reference/objectivec/1418956-nsobject/1571952-retaincount>
>> Do not use this method.
On MMM Apps I look at retainCount all the time for debugging, it’s not that you shouldn't use it, its more you shouldn’t *rely* on it in active code. The value may not be what you expect in that it *might* greater, however if you know what your code is doing and you realise that the OS may change, or know that the object in question has no possibility of being referred to by the OS, it can be useful for debugging purposes.
For instance on thing I’ve done in the past is to override the “retain” and “release”, etc. methods on certain objects and hold my own retain count as a separate property of the object, then if “retainCount” is not equal to the private retain count, you know the OS has retained it.
Cheers
Dave
_______________________________________________
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