Swift: How to (easily) Calculate two numbers

Doing calculations and showing the answer in Swift is really easy. This example will do just that and print the answer to the terminal.  But you could change the code to show the problems and the answer in a UILabel. Here’s the code: import UIKit import Foundation let firstNumber = 56 let secondNumber = 23 […]

CONTINUE READING....

Swift: How to sort an Array

Sometimes, an app needs to shot the information inside an array. Here’s a simple way to sort an array and print it to the console: import UIKit import Foundation var names = [“Kelly”,”Michael”,”Danny”,”Sam”,”Ralph”,”Cathy”,”Thomas”,”Scott”] names.sort() print (names) First, you put information inside the array. Then, you use the sort command. Finally, you print the results to the console, […]

CONTINUE READING....

Swift: How to use an Array to Randomly Select a String

If you wish to make an app that randomly selects a word or a phrase, then you’ll need to use an array.  An array is a group of strings, numbers, or anything else. Such as: let array = [“Heads”,”Tails”] Since we want to randomly select a word from this array, we need to use the arc4random statement, […]

CONTINUE READING....