Example 1: swift append element to array
anArray.append("This String")
anArray += ["Moar", "Strings"]
anArray.append(contentsOf: ["Moar", "Strings"])
anArray.insert("This String", at: 0)
anArray.insert(contentsOf: ["Moar", "Strings"], at: 0)
Example 2: 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
print(setOfArrays as [[Any]0+x][0])
}
Example 3: how to insert element at start of the array ios swift
someArray.insert(someValue, atIndex: 0)
Example 4: swift append to array
var numbers = [1, 2, 3, 4, 5]
numbers.append(100)
print(numbers)
Example 5: add to beginning of array swift
someArray.insert(someValue, at: 0)