Re: how to create a NSMenuItem without memory leaks
Re: how to create a NSMenuItem without memory leaks
- Subject: Re: how to create a NSMenuItem without memory leaks
- From: Conrad Shultz <email@hidden>
- Date: Mon, 16 May 2011 18:56:16 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 5/16/11 6:16 PM, Nick Zitzmann wrote:
>> Plus, you almost never want to use -allocWithZone:. Zones are a
>> particularly arcane subject and explicit determination of a zone is
>> best avoided.
>
> That's not true with NSMenu; the OP actually had it right:
> <http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenu_Class/Reference/Reference.html#//apple_ref/doc/uid/20000267-menuZone>
I know that one CAN specify zones (and that NSMenu has methods to
support that), but why is it desirable/necessary to use them in this
case? My assumption, absent documentation to the contrary, is that
framework classes have overridden -alloc to set appropriate zones
internally.
Consistent with my previous assumption, searching through the
"Application Menu and Pop-up List Programming Topics" reveals no mention
of zones at all, and all code samples therein simply use -alloc (whether
in the case of NSMenu or NSMenuItem). It looks like the "MenuMadness"
sample application uses allocWithZone, but no comment is made in the
code as to why.
I would appreciate for my own edification some deeper explanation.
Every third-party treatise I've seen (particularly Hillegass' intro book
and Buck's "Cocoa Design Patterns") discourages working with zones, as
does (albeit weakly) Apple's own memory performance docs ("In reality,
the overhead of zones often eliminates the performance advantages
associated with the zone.").
If I've been doing things wrong I want to fix them.
- --
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFN0dXAaOlrz5+0JdURAqbvAJ995F07WSJnzEJ1jfnx7s/Cj9OhkgCcCtG+
OSY61cOkly1Bh5yONwyGhr4=
=6iH0
-----END PGP SIGNATURE-----
_______________________________________________
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