Skip to content

Instantly share code, notes, and snippets.

@fuxingloh
Last active January 9, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuxingloh/1878de53691b79878661 to your computer and use it in GitHub Desktop.
Save fuxingloh/1878de53691b79878661 to your computer and use it in GitHub Desktop.
Camel case string extension for swift
extension String {
// Camel case
var camelCased: String {
return self.characters.split{$0 == " "}.map(String.init).map{$0.capitalizedString}.joinWithSeparator(" ")
}
var capitalizeFirst:String {
var result = self
result.replaceRange(startIndex...startIndex, with: String(self[startIndex]).capitalizedString)
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment