swift array add element code example
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 insert element at start of the array ios swift
someArray.insert(someValue, atIndex: 0)
Example 3: swift append to array
var numbers = [1, 2, 3, 4, 5]
numbers.append(100)
print(numbers)
Example 4: add to beginning of array swift
someArray.insert(someValue, at: 0)