Re: Cocoa class extension best practice
Re: Cocoa class extension best practice
- Subject: Re: Cocoa class extension best practice
- From: Andy Lee <email@hidden>
- Date: Tue, 15 Oct 2013 17:37:31 -0400
On Oct 15, 2013, at 4:30 PM, Steve Mills <email@hidden> wrote:
> On Oct 15, 2013, at 14:50:51, Steve Mills <email@hidden> wrote:
>
>> NSArray* items = [self itemArray];
>>
>> for(NSMenuItem* item in items)
>> blah;
>>
>> [items release];
>
>
> Ah, this one won't work (I didn't try it before when I wrote my original message) because itemArray actually does return a new *immutable* array,
itemArray is declared to return an NSArray, so you should treat it as immutable whether or not it happens to return a mutable array. In any case, its mutability has nothing to do with whether itemArray is leaking.
> but it's not release-able. Doing so produces a crash.
This would be expected if itemArray isn't really leaking. FWIW, I did a quick test, calling itemArray hundreds of times, and Leaks didn't report any leaks. Is it possible the arrays you are leaking are elsewhere? I'm running 10.9, so if you're running an earlier OS it's also possible there was a leak and Apple fixed it.
--Andy
_______________________________________________
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