Swift Capitalize words, How to

Swift Capitalize, How to

Swift Capitalize is done with a string instance property. Check the example below to see how to use it. There is also a link at bottom to Apples Swift documentation.
let str = “first, second, third”
print(str.capitalized)

This will output: First, Second, Third

Swift Capitalize

It will capitalize every word in this string. Lets remove the commas and see what happens.

Change str = “first second third”

The output now will be: First Second Third

Check Apple Swift Capitalizion documentation for more information about the string instance property.

Swift Capitalizion
Produce a string with the first character from each word changed to the corresponding uppercase value.

About Author

Related Posts

Xcode 9 iOS icon sizes

Xcode 9 iOS icon sizes overview

Xcode 9 iOS icon sizes overview Xcode 9 iOS icon sizes overview. They keep adding more and more icon sizes. Xcode 9 has the most icon sizes…

Xcode 9 uiimage image not shown

Xcode 9 uiimage image not shown

Xcode 9 uiimage image not shown Working on some ios apps created with Xcode 8 and your images don’t show after upgrading to Xcode 9? Took me awhile…

Xcode 8 iOS icon sizes overview

Xcode 8 iOS icon sizes overview Xcode 8 iOS icon sizes overview. There are even more icon sizes since Xcode 7. And it can be an extra challenging…

Swift Debian

Swift Debian 8 (Jessie)

Swift Debian 8 (Jessie) Swift, Apples new programming language, to take over for Objective C has been open source for some time now. It only took at…

didMove never get called

Xcode – didMove never get called

didMove never get called in Xcode? didMove never get called when creating a new project with Xcode using the Game template. I selected Swift and SpriteKit. I…

Swift Change UIButton text

Swift Change UIButton text

Swift Change UIButton text How to in Swift change UIButton text?A common mistake, also done by myself some time ago, is to try to change it through…

Leave a Reply