Skip to content

Instantly share code, notes, and snippets.

@marlonjames71
Last active July 17, 2020 15:55
Show Gist options
  • Save marlonjames71/2e9d922a5bfad0d3102cb28519f33e6a to your computer and use it in GitHub Desktop.
Save marlonjames71/2e9d922a5bfad0d3102cb28519f33e6a to your computer and use it in GitHub Desktop.
NSObject Protocol Conformance
import Foundation
protocol NextObject: AnyObject, Hashable {
func isEqual(_ object: Any?) -> Bool
var hash: Int { get }
var superclass: AnyClass? { get }
func `self`() -> Self
func perform(_ aSelector: Selector!) -> Unmanaged<AnyObject>!
func perform(_ aSelector: Selector!, with object: Any!) -> Unmanaged<AnyObject>!
func perform(_ aSelector: Selector!, with object1: Any!, with object2: Any!) -> Unmanaged<AnyObject>!
func isProxy() -> Bool
func isKind(of aClass: AnyClass) -> Bool
func isMember(of aClass: AnyClass) -> Bool
func conforms(to aProtocol: Protocol) -> Bool
func responds(to aSelector: Selector!) -> Bool
var description: String { get }
}
extension NextObject {
func isEqual(_ object: Any?) -> Bool {
guard let rhs = object as? Self else { return false }
return self == rhs
}
var hash: Int {
return hashValue
}
var superclass: AnyClass? {
return nil
}
func `self`() -> Self {
return self as Self
}
func perform(_ aSelector: Selector!) -> Unmanaged<AnyObject>! {
perform(aSelector)
}
func perform(_ aSelector: Selector!, with object: Any!) -> Unmanaged<AnyObject>! {
perform(aSelector, with: object)
}
func perform(_ aSelector: Selector!, with object1: Any!, with object2: Any!) -> Unmanaged<AnyObject>! {
perform(aSelector, with: object1, with: object2)
}
func isProxy() -> Bool {
return !(self is NSObject)
}
func isKind(of aClass: AnyClass) -> Bool {
let ttt = type(of: aClass)
return self is ttt
}
func isMember(of aClass: AnyClass) -> Bool {
//
}
func conforms(to aProtocol: Protocol) -> Bool {
//
}
func responds(to aSelector: Selector!) -> Bool {
//
}
var description: String {
return ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment