Skip to content

Instantly share code, notes, and snippets.

View casademora's full-sized avatar

Saul Mora casademora

View GitHub Profile
@casademora
casademora / gist:753834752f3cb43b9b44
Last active February 25, 2019 21:22
Private func in swift are hidden from the ObjC runtime
import Foundation
class Testing : NSObject
{
private func privateWork() {
}
internal func internalWork(){
}
@casademora
casademora / gist:3b784e57bd09c0bc9147
Last active May 17, 2017 01:08
Simple Outline for Cache layer in Swift
//: Playground - noun: a place where people can play
import UIKit
protocol DataSource {
func fetchValue() -> String?
}
protocol DataSourceCacheStrategy {
func retrieve<T>(from: [DataSource], using: DataSource -> T?) -> T?
@casademora
casademora / gist:443dad5d16d095f8747a
Created July 9, 2015 19:14
Implement a method incorrectly by using generic rather than protocol parameter crashes clang compiler
protocol Thing {
var name: String { get }
}
protocol UsingThing {
func doSomething(with: Thing)
}
struct Test: UsingThing {
@casademora
casademora / gist:c4b19d8503767479c0e05a836de4aa4c
Last active August 26, 2016 02:39
Animation behaviors demo from Shanghai Cocoaheads
//
// ViewController.swift
// BehaviorsDemo
//
// Created by Saul Mora on 8/25/16.
// Copyright © 2016 Magical Panda. All rights reserved.
//
import UIKit
@casademora
casademora / gist:9581611f69a59a511992389658c59e00
Created October 28, 2016 03:39
Dynamic Swift Demo Source
//: Playground - noun: a place where people can play
import UIKit
public protocol Maths
{
func doMath(left: Double, right: Double) -> Double
}
class Addition: NSObject, Maths
//: Playground - noun: a place where people can play
//To try out this code, copy and paste into a new Xcode playground.
import UIKit
class Operation: NSObject
{
let nextOperation: Operation?
init(next: Operation? = nil)
{