Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gblancogarcia
gblancogarcia / AppManager.swift
Created January 5, 2016 16:15
Swift 2.1: singleton pattern
class AppManager {
static let sharedInstance = AppManager()
private init () {
}
}
@gblancogarcia
gblancogarcia / CircleNode.swift
Created January 3, 2016 14:26
SpriteKit: creating a resizable circle with a ripple effect animation
import SpriteKit
class CircleNode: SKShapeNode {
var radius: CGFloat {
didSet {
self.path = CircleNode.path(self.radius)
}
}
@gblancogarcia
gblancogarcia / ButtonNode.swift
Last active January 3, 2016 14:27
SpriteKit: creating a custom button
import SpriteKit
protocol ButtonNodeResponder: class {
func buttonTriggered(button: ButtonNode)
}
class ButtonNode: SKSpriteNode {
var identifier: String?
var responder: ButtonNodeResponder?
@gblancogarcia
gblancogarcia / AppDelegate.swift
Last active January 27, 2023 18:00
Core Data: preloading an existing SQLite database
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return true
@gblancogarcia
gblancogarcia / UTF-8 encoding
Last active April 21, 2017 10:33
UTF-8 encoding
\u00e0 -> à
\u00e1 -> á
\u00c0 -> À
\u00c1 -> Á
\u00e8 -> è
\u00e9 -> é
\u00c8 -> È
\u00c9 -> É
@gblancogarcia
gblancogarcia / gist:6781472
Created October 1, 2013 16:43
Random UIColor
// Gets a random UIColor.
- (UIColor *)randomColor
{
CGFloat hue = (arc4random() % 256 / 256.0f);
CGFloat saturation = (arc4random() % 128 / 256.0f) + 0.5f;
CGFloat brightness = (arc4random() % 128 / 256.0f) + 0.5f;
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1.0f];
return color;
}