swift Array<String>() code example

Example 1: how to obtain array in array in swift

import UIKit

var str = "Hello, playground"

var setOfQuestion = ["q1","q2","q3","q4","q5"]

var setOfAnswers = ["A1","A2","A3","A4","A5"]

var setOfImages = ["Img1","Img2","Img3","Img4","Img5"]

var setOfArray = [[1,2,3,4],[5,6,7,8],[9,10,11],[12,13,14],[15,16]]

var setOfArrays = [setOfQuestion,setOfAnswers,setOfImages,setOfArray] as [Any]
for n in 0...3{
    let x = n
    //Not able to get array from arry
    print(setOfArrays as [[Any]0+x][0])

}

Example 2: swift append to array

var numbers = [1, 2, 3, 4, 5]
numbers.append(100)
print(numbers)
// Prints "[1, 2, 3, 4, 5, 100]"