swift 字符串,数组,字典 的那些事<三>

<三>字典

//声明一个空的dictionary


var dicTest:Dictionary<String,String>=Dictionary<String,String>()


dicTest=["一号种子":"vg","二号种子":"lgd","三号种子":"ehome"]


//取得一号种子


dicTest["一号种子"]


//更改一号种子

dicTest["一号种子"]="黑马ig"


//删除三好种子


dicTest.removeValueForKey("三号种子")


//遍历字典


for (key,value) in dicTest{


  println(key)

  

  println(value)


}


for key in dicTest.keys{


    println(key)


}


for value in dicTest.values{

    println(value)

}


你可能感兴趣的:(swift 字符串,数组,字典 的那些事<三>)