Henrik Hanssen
Henrik Hanssen

Reputation: 153

How to capitalize each word of a NSString

I am trying to figure out how to take a given NSString and convert it to camel case. I have seen lots of code samples out there for going back and forth between underscores_ and camel-case, but I am dealing with strings that are capitalized.

So if I had the string: 12345 SAMPLE STREET #12 or 789 N HASKELL STREET, how would I be able to convert those to 12345 Sample Street #12 and 789 N Haskell Street?

Sorry if it's a stupid question, but I'm pretty new to the objective-c / cocoa frameworks world.

Upvotes: 15

Views: 8967

Answers (1)

Dave DeLong
Dave DeLong

Reputation: 243146

-[NSString capitalizedString]

Upvotes: 78

Related Questions