Skip to content

Instantly share code, notes, and snippets.

@alanzeino
Created July 26, 2017 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanzeino/832e208410fca75562f277863be83a95 to your computer and use it in GitHub Desktop.
Save alanzeino/832e208410fca75562f277863be83a95 to your computer and use it in GitHub Desktop.
//
// OurCache.swift
// ConflictingSymbolsViaProtocolExtensions
//
// Created by Alan Zeino on 7/19/17.
// Copyright © 2017 Alan Zeino. All rights reserved.
//
import Foundation
protocol Caching {
func objectForKey(_ key: AnyObject) -> AnyObject?
func removeObjectForKey(_ key: AnyObject)
}
class OurCache: NSCache<AnyObject, AnyObject>, Caching { }
let theCache = OurCache()
let obj = theCache.object(forKey: "foo" as AnyObject)
@alanzeino
Copy link
Author

Foundation.NSCache:8:15: error: unavailable instance method 'objectForKey' was used to satisfy a requirement of protocol 'Caching'
    open func objectForKey(_ key: KeyType) -> ObjectType?
              ^
/Users/alan/Desktop/ConflictingSymbolsViaProtocolExtensions/ConflictingSymbolsViaProtocolExtensions/OurCache.swift:12:10: note: requirement 'objectForKey' declared here
    func objectForKey(_ key: AnyObject) -> AnyObject?
         ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment