Swift 4 for Absolute Beginners by Stefan Kaczmarek Brad Lees & Gary Bennett

Swift 4 for Absolute Beginners by Stefan Kaczmarek Brad Lees & Gary Bennett

Author:Stefan Kaczmarek, Brad Lees & Gary Bennett
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


Now the dictionary will contain only firstName and lastName. Remember that dictionaries are not ordered. You cannot rely on the order, but there will be times when you need to iterate over a dictionary. This is done in a manner similar to arrays. The main difference is that in an array, you assign one variable, while in a dictionary , you need to assign the key and the value. See Listing 8-7.

1 var person: [String: String] = ["firstName": "John", "lastName": "Doe"]

2 for (myKey, myValue) in person {

3 print(myKey + ": " + myValue)

4 }

Listing 8-7.Iterating over a dictionary



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.