• 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: Instance or Class Methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instance or Class Methods?


  • Subject: Re: Instance or Class Methods?
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Fri, 20 Jun 2008 21:16:26 -0500

On Fri, Jun 20, 2008 at 9:11 PM, Brian Norwood <email@hidden> wrote:
> NSString *stuff = [NSString stringWithString:otherStuff];
>
> or
>
> NSString *stuff = [[NSString alloc] initWithString:otherStuff];

Those aren't equivalent statements, unless you're running under
garbage collection.

> The question is this: is there an advantage to one over the other, and why?
> If so, is this something I should determine on a case by case basis? Is
> +stringWithString: just a shortcut for +alloc and -initWithString:?

It's a shortcut for [[[NSString alloc] initWithString:aString] autorelease].
_______________________________________________

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: 
 >Instance or Class Methods? (From: Brian Norwood <email@hidden>)

  • Prev by Date: Instance or Class Methods?
  • Next by Date: Re: Save animation to QuickTime movie?
  • Previous by thread: Instance or Class Methods?
  • Next by thread: getting the selected object from an NSTableView causes problems
  • Index(es):
    • Date
    • Thread