Reader small image

You're reading from  Swift Cookbook - Second Edition

Product typeBook
Published inFeb 2021
Reading LevelIntermediate
PublisherPackt
ISBN-139781839211195
Edition2nd Edition
Languages
Tools
Right arrow
Authors (2):
Keith Moon
Keith Moon
author image
Keith Moon

Keith Moon is an award-winning iOS developer, author and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects both fully Swift, and mixed Swift and Objective-C. Keith has been invited to speak about Swift development in conferences from Moscow to Minsk and London.
Read more about Keith Moon

Chris Barker
Chris Barker
author image
Chris Barker

Chris Barker is an iOS developer and tech lead for fashion retailer N Brown (JD Williams, SimplyBe, Jacamo), where he heads up the iOS team. Chris started his career developing .NET applications for online retailer dabs (now BT Shop) before he made his move into mobile app development with digital agency Openshadow (now MyStudioFactory Paris). There, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, and the Paris Metro. Chris often attends and speaks at local iOS developer meetups and conferences such as NSManchester, Malaga Mobile, and CodeMobile.
Read more about Chris Barker

View More author details
Right arrow

Handling all cases with switch

switch statements allow you to control the flow of execution by testing one specific value in multiple ways. In Objective-C and other languages, switch statements can only be used on values that can be represented by an integer, and are most commonly used to make decisions based on enumeration cases.

As we have seen, enumerations have become a lot more powerful in Swift, as they can be based on more than just integers, and so too can switch statements.

switch statements in Swift can be used on any type and have advanced pattern-matching functionality.

In this recipe, we will explore both simple and advanced usage of switch control flow statements to control logic.

Getting ready

If you are old enough to remember the early days of the home computer, you may also remember text-based adventures. These were simple games that usually described a scene and then let you move around by typing a command to move north, south, east, or west. You would find and pick...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Swift Cookbook - Second Edition
Published in: Feb 2021Publisher: PacktISBN-13: 9781839211195

Authors (2)

author image
Keith Moon

Keith Moon is an award-winning iOS developer, author and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects both fully Swift, and mixed Swift and Objective-C. Keith has been invited to speak about Swift development in conferences from Moscow to Minsk and London.
Read more about Keith Moon

author image
Chris Barker

Chris Barker is an iOS developer and tech lead for fashion retailer N Brown (JD Williams, SimplyBe, Jacamo), where he heads up the iOS team. Chris started his career developing .NET applications for online retailer dabs (now BT Shop) before he made his move into mobile app development with digital agency Openshadow (now MyStudioFactory Paris). There, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, and the Paris Metro. Chris often attends and speaks at local iOS developer meetups and conferences such as NSManchester, Malaga Mobile, and CodeMobile.
Read more about Chris Barker