Re: How is this an "incorrect decrement of a reference count"?
Re: How is this an "incorrect decrement of a reference count"?
- Subject: Re: How is this an "incorrect decrement of a reference count"?
- From: Roland King <email@hidden>
- Date: Tue, 20 Mar 2012 06:47:17 +0800
And do you now understand why you are releasing the wrong thing? if not please go read the replies from Eeyore and I again, you cannot release the result of a method call which returns an object you don't own. Your code as written is a hack, it happens to work because the property is a simple retained one and you get bsck the object you didn't keep when you created it, but it's wrong and it's dangerous (change the property to 'copy' and then see how bad it gets). Then either use a temporary or use autorelease as I suggested (and I see David Duncan has too) so that you are releasing the object you *do* own and both the leak and the analyser error (and your bad code) will go away.
On Mar 20, 2012, at 6:22 AM, G S wrote:
> On Mon, Mar 19, 2012 at 6:18 AM, Roland King <email@hidden> wrote:
> No, the analyzer is right and your code is somewhat confused. I'm trying to figure out how you ended up with code like that, did you find you had an extra retain somewhere and need to get rid of it?
>
> Yes. The allocated object has a retain count of 1, and the property is set to retain. So there's the extra retention.
>
> That's all it tells you, ie somewhere you either have
>
> @synthesize imagePickerController=_imagePIckerController;
>
> Exactly. Without the release, the analyzer complains about leaks, and does so on ALL cases.
_______________________________________________
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