//Dictionary (unordered data set)*the dictionary type of Swift is bridged to the Nsdictionary class of the foundation. * Format [:]/Dictionary<key, value>()*Let immutable dictionary*var variable dictionary//Note:*the key type of a dictionary must follow the Hashable protocol//declaring a dictionaryLet dict: [string:double]//Initialize DictionaryDict = ["score":99.9]//dict = ["Age": +]//define an empty dictionaryLet Dict1 =[String:int] ()//to define a dictionary with values//[String:nsobject] Type is the most common type of iOS developmentvar dict2 = ["name":"SSC"," Age": to,"score":59.5]//Getdict2["name"] //Increase//as long as there is no corresponding key in the dictionary will be addeddict2["Rank"] =1Dict2//DeleteDict2.removevalueforkey ("Rank") dict2 ["Name": "SSC", "age": +, "score": 59.5]//Traverse forKeyinchdict2.keys{Print (key)} forValueinchdict2.values{Print (value)} for(Key, value)inchdict2{print (key) print (value)}//Mergingvar dict3 = ["name":"SSC"," Age": to]var Dict4= ["Rank":1,"score":99.9] for(Key, value)inchdict4 {Dict3[key]=value}dict3 ["Score": 99.90000000000001, "age": +, "rank": 1, "name": "SSC"]
Swift Learning-----Dictionary