Swift的下标代码

//下标subscript,可以有多个参数

subscript(index:int)->

{

get{

return images[index]

}

set{

images[index]=newValue

}

}

func getImage(index:Int)->

{

return images[index]

}

let xc=XiangCe()

xc.getImage(0)

xc[0]

xc[0]=100

xc[0]

原文地址:https://www.cnblogs.com/tyty/p/4931190.html