Skip to content

Commit

Permalink
Updated to Swift 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahimhass committed Jul 20, 2021
1 parent b4b2ea5 commit 7e5268c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions SwiftyInvocation/Classes/SwiftyInvocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//
//

import Foundation

enum SwiftyInvocationError: Error {
case noMethod
case noImplementation
Expand All @@ -27,12 +29,11 @@ enum SwiftyInvocationError: Error {
/// - selector: The selector of which you want to retrieve the implementation.
/// - type: The implementation type in @convention (c)
/// - Returns: The implementation
public func swift_getImplementation<T>(object: AnyObject, selector: Selector, type: T.Type) throws -> T {
guard let method = class_getInstanceMethod(type(of: object), selector) else {
public func swift_getImplementation<T>(object: AnyClass, selector: Selector, type: T.Type) throws -> T {
guard let method = class_getInstanceMethod(object, selector) else {
throw SwiftyInvocationError.noMethod
}
guard let implementation = method_getImplementation(method) else {
throw SwiftyInvocationError.noImplementation
}

let implementation = method_getImplementation(method)
return unsafeBitCast(implementation, to: T.self)
}

0 comments on commit 7e5268c

Please sign in to comment.