我想通过将元素附加到现有数组而不修改它来获得新数组。 NSArray
有arrayByAddingObjectsFromArray()
,例如:
let numbers = (["one", "two", "three"] as NSArray).arrayByAddingObjectsFromArray(["four", "five"]) as! [String]
是否存在Swift Array
结构的等价物,这种结构会使NSArray
不需要桥接?
答案 0 :(得分:4)
let existingArray = ["four", "five"]
let numbers = ["one", "two", "three"] + existingArray