Skip to content

Instantly share code, notes, and snippets.

@mohamede1945
mohamede1945 / Cache.swift
Created May 4, 2017
NSCache wrapper that works with Swift structs
View Cache.swift
private class ObjectWrapper {
let value: Any
init(_ value: Any) {
self.value = value
}
}
private class KeyWrapper<KeyType: Hashable>: NSObject {
let key: KeyType
@mohamede1945
mohamede1945 / Cache.swift
Last active Sep 1, 2017
General purpose Cache for Swift, No AnyObject restrictions! Can be used with Structs
View Cache.swift
extension Hashable {
var hashNumber: NSNumber {
return NSNumber(value: hashValue)
}
}
private class ObjectWrapper {
let value: Any
init(_ value: Any) {
View ProgrammerAssertions.swift
//
// ProgrammerAssertions.swift
// Assertions
//
// Created by Mohamed Afifi on 12/20/15.
// Copyright © 2015 mohamede1945. All rights reserved.
//
import Foundation