• 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: Quick question! About init...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quick question! About init...


  • Subject: Re: Quick question! About init...
  • From: Charles Srstka <email@hidden>
  • Date: Fri, 2 Aug 2002 18:41:19 -0500

Well, the first difference is that the second example won't compile - you have too many left brackets. ;-)

The main difference between the two, though, is that the second example is known as a "convenience constructor" and will return an autoreleased object, while the first will return a retained object that you will need to release manually later.

[NSString stringWithString:name];

is actually equivalent to:

[[[NSString alloc] initWithString:name] autorelease];

On Friday, August 2, 2002, at 06:31 PM, Ernst Persson wrote:

Is:

playerName[player] = [[NSString alloc] initWithString:name];

equal to:

playerName[player] = [[NSString stringWithString:name];

If not, what's the difference?

//ernie
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Quick question! About init... (From: Ernst Persson <email@hidden>)

  • Prev by Date: Spellchecker dictionary for OS X
  • Next by Date: Re: Quick question! About init...
  • Previous by thread: Quick question! About init...
  • Next by thread: Re: Quick question! About init...
  • Index(es):
    • Date
    • Thread