Re: NSString camel case
Re: NSString camel case
- Subject: Re: NSString camel case
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 11 Apr 2009 23:45:46 -0700
On Apr 11, 2009, at 11:35 PM, Devraj Mukherjee wrote:
My app receives strings from a web service that look like
"everything_else" (no quotes) I would like to convert these strings to
"Everything Else". My initial attempts were going to be using a loop
through the string inspecting it for occurances but I think that will
make the application slow as there are a lot of these strings.
Can I use regular expressions or certainly a better way? Any ideas?
NSString *result = [[originalString
stringByReplacingOccurrencesOfString:@"_" withString: @" "]
capitalizedString];
This is about the fastest straightforward means of doing what you
described, assuming that your strings are as simple as you describe in
all cases. There are faster ways, but they aren't nearly so simple.
Thinking something is going to be slow is very different from
something actually being slow enough to impact your application's
user's experience.
b.bum
_______________________________________________
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