Swift Arrays
A Swift Array stores like kind of elements. The elements in an array are ordered and can be accessed using index.
Array Basics
The following tutorials cover basics of Swift arrays like creation, initialization, properties of array, etc.
- Swift – Create an empty array
- Swift – Create empty string array
- Swift – Create an array of specific size
- Swift – Create an array with default value
- Swift – Create an array with initial values
- Swift – Initialize array
- Swift – Initialize array with different datatype values
- Swift – Integer array
- Swift – String array
- Swift – Print array
- Swift – Get array size
- Swift – Convert array to string
Access
The following tutorials cover scenarios on how to access elements in an array.
- Swift – Access elements of array using index
- Swift – Get first element of array
- Swift – Get last element of array
- Swift – Get random element from array
- Swift – Array forEach()
- Swift – Loop over array using For loop
- Swift – Loop over array using While Loop
- Swift – Loop over array using forEach Loop
Checks
The following tutorials cover scenarios where we need to check a given condition based on the whole array or elements in the array.
- Swift – Check if array is empty
- Swift – Check if array contains specific element
- Swift – Check if string array contains a specific string
- Swift – Check if two arrays are equal
- Swift – Check if all the elements in array satisfy given condition
Find
The following tutorials cover scenarios on how to find elements in an array based on a given condition.
- Swift – Find index of element in array
- Swift – Find smallest element in array
- Swift – Find largest element of array
Modify / Transform
The following tutorials cover scenarios on how to how to modify an array.
- Swift – Append an element to array
- Swift – Append an array to another array
- Swift – Append an integer to array
- Swift – Append string to array
- Swift – Concatenate two arrays
- Swift – Convert string array to integer array
- Swift – Delete first N elements of array
- Swift – Delete last N elements of array
- Swift – Delete first element of array
- Swift – Delete last element of array
- Swift – Insert an element in array at specific index
- Swift – Insert elements of another array at specific index in this array
- Swift – Remove an element from array
- Swift – Remove elements from array based on a condition
- Swift – Remove all elements from array
- Swift – Replace an element in array
- Swift – Reverse array
Sort
The following tutorials cover scenarios on how to sort elements in an array in ascending or descending order, based on a given condition.
- Swift – Sort integer array in ascending order
- Swift – Sort integer array in descending order
- Swift – Sort string array lexicographically
Filter
The following tutorials cover scenarios on how to filter elements in an array.