Skip to content

Instantly share code, notes, and snippets.

@mohamede1945
mohamede1945 / Cache.swift
Created May 4, 2017 19:03
NSCache wrapper that works with Swift structs
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 September 1, 2017 17:52
General purpose Cache for Swift, No AnyObject restrictions! Can be used with Structs
extension Hashable {
var hashNumber: NSNumber {
return NSNumber(value: hashValue)
}
}
private class ObjectWrapper {
let value: Any
init(_ value: Any) {
//
// ProgrammerAssertions.swift
// Assertions
//
// Created by Mohamed Afifi on 12/20/15.
// Copyright © 2015 mohamede1945. All rights reserved.
//
import Foundation