• 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: NSString camel case
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSString camel case (From: Devraj Mukherjee <email@hidden>)

  • Prev by Date: NSString camel case
  • Next by Date: Re: NSString camel case
  • Previous by thread: NSString camel case
  • Next by thread: Re: NSString camel case
  • Index(es):
    • Date
    • Thread