我有一个多维数组。它就像[["1","2","3"]]
,我如何访问"1"
?
详细了解......
lazy var data : [[NSURL]] = {
var array = [[NSURL]]()
if array.count == 0 {
var index = 0
var section = 0
for image in images {
if array.count <= section {
array.append([NSURL]())
}
array[section].append(image)
index += 1
}
}
return array
}()
使用print(data)
,我可以访问:
[["firstUrl", "secondUrl", "thirdUrl"]]
如何访问"first"
?
答案 0 :(得分:1)
你可以这样做:array[0][0]
答案 1 :(得分:0)
例如枚举如下:
var dict = [["1","2","3"]]
for (index, item) in dict.enumerate() {
//hear you enumerate []
for (index, item) in item.enumerate() {
//hear you enumerate ["1","2","3"]
print("Found \(item) at position \(index)")
}
}