senty senty - 7 months ago 14
Swift Question

Access GrandChild of Multidimensional Array in Swift

I have a multi-dimensional array. It gets like

[["1","2","3"]]
, how can I access
"1"
?

To get more in detail...

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
}()





With
print(data)
, I can access:

[["firstUrl", "secondUrl", "thirdUrl"]]


How can I access
"first"
?

Answer

You can do it like this: array[0][0]

Comments