import UIKit class ArrayObject : NSObject { var numbers = [1,2,3,4,5] func shuffleNumbers() { numbers.shuffle() } } extension MutableCollection where Indices.Iterator.Element == Index { /// Shuffles the contents of this collection. mutating func shuffle() { let c = count guard c > 1 else { return } for (unshuffledCount, firstUnshuffled) in zip(stride(from: c, to: 1, by: -1), indices) { let d: IndexDistance = numericCast(arc4random_uniform(numericCast(unshuffledCount))) guard d != 0 else { continue } let i = index(firstUnshuffled, offsetBy: d) swap(&self[firstUnshuffled], &self[i]) } } } let array = ArrayObject() array.shuffleNumbers() print(array.numbers[1])

## Swift Tutorial

Swift Tutorial

## Swift Programming Tutorial For Beginners 2015

Video Tutorial For Beginners

https://www.youtube.com/watch?v=I0Meyb4ejN4

## iOS Apps: Making a quiz game

Making a quiz game with Swift.

## Swift: Getting the average

Another method to get the average.

import UIKit func calculateAverage(total: Int, countOfNumbers: Int) -> Int { return total / countOfNumbers } func average(algorithm: (Int, Int) -> Int, numbers: Int...) -> Int { var countOfNumbers = 0 var total = 0 for number in numbers { total += number countOfNumbers++ } return algorithm(total, countOfNumbers) } let avg = average(calculateAverage, numbers: 3, 9, 6) print(avg)