Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Beginning Swift
  • Toc
  • feedback
Beginning Swift

Beginning Swift

By : Rob Kerr, Kåre Morstøl
4 (1)
close
Beginning Swift

Beginning Swift

4 (1)
By: Rob Kerr, Kåre Morstøl

Overview of this book

Take your first foray into programming for Apple devices with Swift.Swift is fundamentally different from Objective-C, as it is a protocol-oriented language. While you can still write normal object-oriented code in Swift, it requires a new way of thinking to take advantage of its powerful features and a solid understanding of the basics to become productive.
Table of Contents (10 chapters)
close

Challenge


We'll tie together a variety of Swift language techniques, giving you additional practice to create structs, functions, data types, and optionals, and use flow control structures.

To solidify your understanding of basic struct and class usage by practicing the creation of each type of object.

  1. Launch Xcode, and create a new playground, then save it to your desktop with the name Activity 5 - Final Activity.playground.

  2. Add the following enum, which will be used to classify customers by gold, silver, and platinum levels. Note that this enum has a rawValue of type String, which we will use while printing customer information:

    enum CustomerType:String {
        case silver = "SILVER"
        case gold = "GOLD"
        case platinum = "PLATINUM"
    }
  3. Create a new Customer struct with a set of String variables, including an optional for country and the variable type to classify the customer into one of the CustomerType categories:

    struct Customer {
        var name: String
      ...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete