This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class PebbleConnector : NSObject, PBPebbleCentralDelegate, PBWatchDelegate { | |
public class var sharedInstance: PebbleConnector { | |
struct Singleton { | |
static let instance = PebbleConnector() | |
} | |
return Singleton.instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Searching for a toString() method in Swift? Use the printable protocol! | |
// Implement Printable protocol and create a description variable | |
// https://developer.apple.com/library/ios/documentation/General/Reference/SwiftStandardLibraryReference/Printable.html | |
class Person : Printable { | |
var name : String! | |
init(name : String) { | |
self.name = name | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func generateRandomIndex(#lower: Int , upper: Int) -> Int { | |
return lower + Int(arc4random_uniform(UInt32(upper - lower + 1))) | |
} | |
// Usage | |
var randomDice : Int = generateRandomIndex(lower: 1, upper: 6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getRandomColor() -> SKColor { | |
var randomRed:CGFloat = CGFloat(drand48()) | |
var randomGreen:CGFloat = CGFloat(drand48()) | |
var randomBlue:CGFloat = CGFloat(drand48()) | |
return SKColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0) | |
} | |
// Usage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SpriteKit | |
import UIKit | |
extension SKColor { | |
convenience init(rgba: String) { | |
var red: CGFloat = 0.0 | |
var green: CGFloat = 0.0 | |
var blue: CGFloat = 0.0 | |
var alpha: CGFloat = 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Grid<T> { | |
var array : Array<Array<T>> | |
let rows : Int | |
let columns : Int | |
init(rows : Int, columns : Int, initialValue: T) { | |
self.rows = rows | |
self.columns = columns | |
self.array = Array<Array<T>>() |
NewerOlder