Re: Cocoa class extension best practice
Re: Cocoa class extension best practice
- Subject: Re: Cocoa class extension best practice
- From: Kyle Sluder <email@hidden>
- Date: Tue, 15 Oct 2013 13:35:32 -0700
On Tue, Oct 15, 2013, at 12:50 PM, Steve Mills wrote:
> We have extended NSMenu so we could add some other methods. Many of the
> methods iterate over the itemArray like so:
>
> for(NSMenuItem* item in [self itemArray])
>
> Instruments shows that we're leaking NSArrays created when itemArray
> returns. I assume whoever wrote these methods was assuming that itemArray
> would simply return the internal NSArray and not make a copy. I guess I
> would make the same assumption since it's not a copy* method.
They shouldn't be leaking. You're correct that -itemArray doesn't follow
the naming convention of an object-creation method (new, alloc, copy,
etc.), so you should not assume a +1 owning reference.
Are you perhaps seeing an autoreleased object hang out longer than you
expected, but not actually get leaked?
--Kyle Sluder
_______________________________________________
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