func test(_ arr: [String]) {
for var i in arr {
withUnsafePointer(to: &i) {
print(" str value \(i) has address: \($0)")
}
}
}
var a = ["1","2","3"]
test(a)
打印结果:
str value 1 has address: 0x00007fff5dff9fc0
str value 2 has address: 0x00007fff5dff9fc0
str value 3 has address: 0x00007fff5dff9fc0
如果我想打印整个数组的地址怎么打?
如果数组里不是字符串,是其他类型,改怎么打?找了很久没找到,特此来提问