Re: Fairly newbie question on strings
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