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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift