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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com