Swift的NSArray一经初始化数据可变但是不能在原有基础上添加新数据
废话不多说
var na:NSArray = ["Pencil","Eraser","Notebkko"]
println(na.count)//Pencil、Eraser、Notebkko
var na:NSArray = ["Pencil","Notebkko"]
var nb:NSArray = ["a","b","c"];
na=nb
println(na.count)//3 此时的na里的值为 abc
*祝不能在原有基础上添加第四个元素
如果添加用NSMutableArray
var nn:NSMutableArray = ["a","c"]
nn.addObject("b")
println (nn. count )//输出为acb 原文链接:https://www.f2er.com/swift/324132.html