• 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: What's with this "new"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's with this "new"?


  • Subject: Re: What's with this "new"?
  • From: Gregory Weston <email@hidden>
  • Date: Mon, 26 Jul 2004 17:31:40 -0400

On Jul 26, 2004, at 10:01 AM, Mark Patterson wrote:

I've just had a look at
http://lists.apple.com/archives/cocoa-dev/2002/Feb/10/
memorymaniarevisted.001.txt
It seems to suggest that +new is not deprecated, but alloc init is
clearer for beginners. So I don't think I should feel too dimodi to use
it if I think it makes the code more readable.

A couple of things to note:

1) IIRC, new is simply implemented as an alloc/init sequence. So using it saves you a couple of keystrokes at the expense of a basically superfluous message send.

2) new is equivalent to alloc/init. But there are no analogous newWithFoo: messages for all the other initializers. It could be argued that the deviation - using new when you want an argless init, and fooWithBar every other time - will actually make the code less readable.

There's nothing _wrong_ with new, but there's really nothing significantly right about it either.

G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: [OT] disable Xcode's undo warning?
  • Next by Date: Re: Stopping on objc exceptions in Xcode
  • Previous by thread: Re: What's with this "new"?
  • Next by thread: Identifying a connected iPod in C or Obj-C
  • Index(es):
    • Date
    • Thread