• 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: Fairly newbie question on strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fairly newbie question on strings


  • Subject: Re: Fairly newbie question on strings
  • From: Douglas Davidson <email@hidden>
  • Date: Thu, 26 Jan 2006 17:23:03 -0800


On Jan 26, 2006, at 5:05 PM, Joshua Scott Emmons wrote:

I guess it depends on if you're after readability or efficiency. If readability is the issue then I think it'd be hard to beat:

[NSString stringWithFormat:@"Today is %@.", nameOfToday];

Your alternative is to do something like:

[[@"Today is" stringByAppendingString:nameOfToday] stringByAppendingString:@"."];

And that's just ugly.

If your concern is efficiency, there's probably some trick dealing with NSMutableString that would be able to do all this for you in fewer cycles. But for all the time it would save you, I'd rather go with the simple and readable -stringWithFormat: any day.


Don't forget localizability, which would militate in favor of the stringWithFormat: version. Also, one should take a look at NSDateFormatter for date-related issues.


Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Fairly newbie question on strings (From: Mike Abdullah <email@hidden>)
 >Re: Fairly newbie question on strings (From: Joshua Scott Emmons <email@hidden>)

  • Prev by Date: Re: Fairly newbie question on strings
  • Next by Date: Universal Binary & Mac OS 10.1
  • Previous by thread: Re: Fairly newbie question on strings
  • Next by thread: Re: Fairly newbie question on strings
  • Index(es):
    • Date
    • Thread