数组和字典 swift

var array = ["A","B"]
var array2:[String] = ["A","B"]
var array3:Array = ["A","B"]
创建
var array = Int
var array2 = Array()
var array3 = Int

count
isEmpty
insert
removeAtIndex
removeLast

遍历
for index in 0,,array.count
{

}
for item in array
{

}
for (index,item) in enumerate(array)
{

}

字典
Dictionary<Int,String>
Dictionary<String,String>

[int:String]
[String:String]

创建
var dict = Dictionary<Int,String>()
var dict2 = String:String

var courses = [1:"语文",2:"数学"]
courses[1]
删除
courses[1] = nil

count
isEmpty

遍历
for (key,value) in courses
{

}

keys
values

posted @ 2016-12-17 00:00  乱笙歌  阅读(181)  评论(0编辑  收藏  举报