FREE TRIAL: Accelerate your app development career with Hacking with Swift+! >>

DAY 80

Project 24, part one

In today’s technique project we’re going to zoom in on one specific detail of Swift programming: strings. Steve Jobs famously said “this is what customers pay us for: to sweat all these details so it's easy and pleasant for them to use our computers,” and strings are a good example of one of those details – they look like they ought to be simple, but if you want to get them right you need to spend some time working at it.

As you’ll see, there’s more to strings than just being a sequence of characters. In fact, Swift’s string handling is the most advanced I’ve seen in any language, and as a result if you play by Swift’s rules you’ll find your apps work great in every conceivable language – something that most developers for other languages need to work hard at.

Today you’re also going to learn an important skill that might cause you to go back and look through earlier projects for places you can use it: how to add formatting to your strings. This is done using a class called NSAttributedString, and although we’re only using it at an introductory level here as your skills progress you’ll learn how it can add images to strings – it’s really powerful!

Today you have four topics to work through, and you’ll learn about string subscripts, contains(where:), NSAttributedString, and more.

Need help? Tweet me @twostraws!


Hacking with Swift is sponsored by Essential Developer

SPONSORED From August 2nd to 8th you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Save your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

100 Days of Swift

The 100 Days of Swift is a free collection of videos, tutorials, tests, and more to help you learn Swift faster. Click here to learn more, or watch the video below.

Back to 100 Days of Swift

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.