Capitalise the first letter of a string in iOS swift
Problem:
I'm having the string i want to convert string first letter to capital letter.How to achieve that?
Solution:
extension String {
func capitalizingFirstLetter() -> String {
let first = String(prefix(1)).capitalized
let other = String(dropFirst())
return first + other
}
}
Comments
Post a Comment