Declaring & Initializing Dictionaries in Swift
Dictionary of String
var stringDict: [String: String] = [String: String]()
OR
var stringDict: Dictionary<String, String> = Dictionary<String, String>()
Dictionary of Int
var stringDict: [String: Int] = [String: Int]()
OR
var stringDict: Dictionary<String, Int> = Dictionary<String, Int>()
Dictionary of AnyObject
var stringDict: [String: AnyObject] = [String: AnyObject]()
OR
var stringDict: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
Dictionary of Array of String
var stringDict: [String: [String]] = [String: [String]]()
OR
var stringDict: Dictionary<String, Array<String>> = Dictionary<String, Array<String>>()
Array of Dictionaries of String
var stringDict: [[String: String]] = [[String: String]]()
OR
var stringDict: Array<Dictionary<String, String>> = Array<Dictionary<String, String>>()
array :() dictionary :{}
print statementslet arr = [] let dict = [:] println("array :\(arr)") println("dictionary :\(dict)")
– nsuinteger