Re: Fairly newbie question on strings
Re: Fairly newbie question on strings
- Subject: Re: Fairly newbie question on strings
- From: Joshua Scott Emmons <email@hidden>
- Date: Thu, 26 Jan 2006 19:05:40 -0600
So I need to get the first bit of string: "Today is "
Add on to it nameOfToday
And then append on to that "."
What would be the best way of achieving this? I am looking at
stringWithFormat of NSString. Would this be the best choice?
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.
Cheers,
-Joshua Emmons
_______________________________________________
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