O'Reilly logo

iOS 9 SDK Development by Janie Clayton, Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Storing Text in Strings

Strings—blocks of textual data—are another essential data type supported in nearly all programming languages, and Swift’s are really great. Let’s start a new playground to try them out: create the playground with File > New > Playground, and call it StringsPlayground.

Of course, right off the bat, the playground template creates a string for us with var str = "Hello, playground", which evaluates as Hello, playground in the results pane.

Since str is defined with the var keyword, it’s a variable, so let’s change it up a bit. Type the following:

 str = str + ​"!!"

This evaluates as Hello, playground!!, and proves that we can combine strings with the + operator. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required