Skip to content

Instantly share code, notes, and snippets.

andymuncey / StructClassBehaviour.swift
Last active Oct 5, 2020
Demonstrates pass by reference vs pass by value difference with Swift struct and class
View StructClassBehaviour.swift
//change this to a struct and verify the change in behaviour
class Number : CustomStringConvertible {
var number: Int
init(_ num: Int) {
number = num
public var description : String {
return "\(number)"
andymuncey / Liskov.swift
Last active Aug 26, 2016
View Liskov.swift
class LiskovPhraseMaker {
//class properties
private var type = "T"
private var subtype = "S"
func modifiedLiskovPhrase() -> String{
return "If \(subtype) is a subtype of \(type), then objects of type \(type) may be replaced with objects of type \(subtype) (i.e., objects of type \(subtype) may substitute objects of type \(type)) without altering any of the desirable properties of that program (correctness, task performed, etc.)"
andymuncey / AddSpriteNode.swift
Last active Aug 29, 2015
Example Swift code to create a rectangular SKSpriteNode with solid colour
View AddSpriteNode.swift
//create node
var rectangleSpriteNode = SKSpriteNode()
//set sprite colour
rectangleSpriteNode.color = UIColor.yellowColor()
//set 100 width by 500 high
rectangleSpriteNode.size = CGSizeMake(100, 50)
//set the position of the node's centre (200 points across, 100 points up)