Last active
July 17, 2020 15:55
-
-
Save marlonjames71/2e9d922a5bfad0d3102cb28519f33e6a to your computer and use it in GitHub Desktop.
NSObject Protocol Conformance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://stackoverflow.com/questions/24245262/call-a-method-from-a-string-in-swift