Skip to content

Commit

Permalink
Method to capitalize only first letter
Browse files Browse the repository at this point in the history
  • Loading branch information
droytbl committed Jun 30, 2015
1 parent 9582efb commit 00e05d8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Swift Extensions/String+TBL.swift
Expand Up @@ -12,6 +12,22 @@ public extension String {
}
}

/**
Capitalize the first letter as opposed to .capitalizedString which lowercases
the string and then capitalizes every word in it.
:returns: Same string with the first letter uppercased
*/
func capitalizeFirstLetter() -> String {
if startIndex == endIndex {
return self
}
let rest = advance(startIndex,1)..<endIndex
let capitalized = self[startIndex...startIndex].uppercaseString + self[rest]

return capitalized
}

public static func localized(key: String, table: String) -> String {
return NSLocalizedString(key, tableName: table, comment: "")
}
Expand Down

0 comments on commit 00e05d8

Please sign in to comment.