//: Playground - noun: a place where people can play import UIKit var dict = [1:"one", 2:"two", 3:"three", 4:"four"] dict.count dict.isEmpty dict[1] dict[66] "课程名称: " + dict[1]! // 添加和修改 dict[5] = "five" dict[4] = "44444" dict.updateValue("2222", forKey: 2); dict // 删除 dict[1] = nil; dict.removeValueForKey(5) dict // 遍历 for (key, value) in dict { print("key:(key) value:(value)") } dict.keys dict.values for key in dict.keys { print(key) } for value in dict.values { print(value) }