AppDelegate.swift: unchanged. Contains three pairs of methods: launch/terminate, foreground/background, active/inactive. See Managing State Transitions and Execution States for Apps.
viewDidLoadmethod of the view controller let the view controller be the delegate of the text view. .
UIViewcontains three subviews: a yellow
UITextField, and a green
Info.plist: the information property list file. Unchanged.
//Look up each state and find its two-letter abbreviation. let dictionary: [String: String] = [ "Alabama": "AL", "Alaska": "AK", "Arizona": "AZ", "Arkansas": "AR", "California": "CA" ];
Update the user instructions in the yellow
textField.textin the dictionary, create the following variable and try to look it up.
let lowercase: String = textField.text!.lowercased();
textField.textin the answer label, create the following variable and display it instead.
let capitalized: String = lowercase.prefix(1).uppercased() + lowercase.dropFirst();
let dictionary: [Int: String] = [ 1492: "Columbus discovers America", 1776: "American Independence", 1929: "Stock market crash", 1969: "Moon landing" ];Change the original
let ikeaWord: String = textField.text!;to
let year: Int = Int(textField.text!)!; //Convert String to Int.
//How many electoral votes does each state have? let dictionary: [String: Int] = [ "AL": 9, //Alabama "AK": 3, //Alaska "AZ": 11, //Arizona "AR": 6, //Arkansas "CA": 55 //California ];Change the original
let meaning: String? = dictionary[ikeaWord];to
let votes: Int? = dictionary[state];