Handling Swipe Gestures in a SpriteKit Game

February 16th, 2018

Filed under: Game Development, iOS Development | Be the first to comment!

When you create a SpriteKit Xcode project, the GameScene.swift file contains functions to handle touch and/or mouse events, depending on the type of SpriteKit project you create. You can also use swipe gestures in SpriteKit games. Supporting swipe gestures requires you to perform two tasks. The first task is to create a swipe gesture recognizer. […]


Swift Functional Programming: Pure Functions

January 15th, 2018

Filed under: iOS Development, Mac Development | 2 comments

A pure function doesn’t reference any data outside of the function. If you supply a given input to a pure function, it always returns the same value. The following is a simple example of a pure function: func increment(value: Int) -> Int { return value + 1 } The increment function is pure because it […]


Swift First Class Functions

January 12th, 2018

Filed under: iOS Development, Mac Development | Be the first to comment!

I considered writing an article about first class functions in Swift, but I came across the following article by John Sundell: First class functions in Swift Sundell’s article covers pretty much everything I would cover in an article on first class functions. The examples are good too. So I decided to link to his article […]


Swift Functional Programming: reduce

January 8th, 2018

Filed under: iOS Development, Mac Development | Be the first to comment!

The reduce function takes all the elements of a collection and combines them into a single value. Supply an initial value and a function or closure (unnamed function) to combine the elements. The following code demonstrates how to calculate the average for a collection of test scores: let testScores = [78, 96, 48, 65, 59, […]


Swift Functional Programming: map

January 3rd, 2018

Filed under: iOS Development, Mac Development | Be the first to comment!

The map function takes all the elements in a collection and applies a function or a closure (an unnamed function) to them. The following code demonstrates using map to multiply each element of an array by itself: let numbers = [1, 2, 3, 4, 5] let squares = numbers.map { return $0 * $0 } […]