• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa class extension best practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Cocoa class extension best practice (From: Steve Mills <email@hidden>)
 >Re: Cocoa class extension best practice (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: dispatch queues and KVO?
  • Next by Date: Re: Cocoa class extension best practice
  • Previous by thread: Re: Cocoa class extension best practice
  • Next by thread: Re: Cocoa class extension best practice
  • Index(es):
    • Date
    • Thread