
- iOS Development with Swift 2
- iOS Development - Home
- iOS Development - Xcode IDE
- iOS Development - First Application
- Making the App Interactive
- iOS Development - Swift Playground
- Making Applications with Swift
- iOS Development - Advanced iOS
- iOS Development - Integrating Maps
- iOS Development - Auto Layouts
- iOS Development - Animations
- Accessing Web Services
- Concurrency Control
- Interview Questions
- iOS Development Useful Resources
- iOS Development - Quick Guide
- iOS Development - Resources
- iOS Development - Discussion
iOS Development with Swift 2 - Arrays
Arrays are the data types that store the same type of data in an ordered list. The same value can appear at multiple indexes/Places in an array.
Operations on an Array
Swift provides multiple operations that we can apply on arrays according to the user Requirement. Some of the most commonly used ones are given below.
var ArrayName = [Datatype]() // Creates an empty Array of Datatype.
var newArray = [Int]() // Creates an empty Integer Array.
newArray = [1,2,3] // Assigns Three Values to the Array.
newArray.count // Prints the count of Array.
newArray.isEmpty // Checks if array is empty.
newArray.append(4) // Adds an element at the end of array.
var firstItem = newArray[0] // creates a variable with value of first element of newArray.
newArray.insert(7, at: 0) // inserts value 7 at 0th index of newArray
newArray.remove(at: 2) // removes value from 2nd index of newArray.
