FREE: Watch my new YouTube videos, Xcode in 20 Seconds! >>

How to convert a string to uppercase letters

Paul Hudson       @twostraws

If you want to convert a string to uppercase – that is, WHERE EVERY LETTER IS A CAPITAL LETTER – you should use the uppercased() method of your string, like this:

let str = "Sunday, Monday, Happy Days"
print(str.uppercased())

That code will print "SUNDAY, MONDAY, HAPPY DAYS" into the Xcode console.

Sponsored You’re already busy updating your app for Swift 4.2 and iOS 12, so why not let Instabug help you find and fix bugs? Add just two lines of code to your project and receive comprehensive reports with all the feedback you need to ship a world-class app – click here to learn more!

Available from iOS 2.0

Did this solution work for you? Please pass it on!

Other people are reading…

About the Swift Knowledge Base

This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.

Hacking with watchOS

Transfer your Swift skills to watchOS the easy way, and learn to build real-world apps in the process!

MASTER SWIFT NOW
Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let me know!

Average rating: 4.3/5

Click here to visit the Hacking with Swift store >>