@@ -69,8 +69,8 @@ final public class Interpose {
6969 _ selName: String ,
7070 methodSignature: MethodSignature . Type = MethodSignature . self,
7171 hookSignature: HookSignature . Type = HookSignature . self,
72- _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature ? )
73- throws -> TypedHook < MethodSignature , HookSignature > {
72+ _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature
73+ ) throws -> TypedHook < MethodSignature , HookSignature > {
7474 try hook ( NSSelectorFromString ( selName) ,
7575 methodSignature: methodSignature, hookSignature: hookSignature, implementation)
7676 }
@@ -80,30 +80,29 @@ final public class Interpose {
8080 _ selector: Selector ,
8181 methodSignature: MethodSignature . Type = MethodSignature . self,
8282 hookSignature: HookSignature . Type = HookSignature . self,
83- _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature ? )
84- throws -> TypedHook < MethodSignature , HookSignature > {
85- let hook = try prepareHook ( selector, methodSignature: methodSignature,
86- hookSignature: hookSignature, implementation)
87- try hook. apply ( )
88- return hook
89-
83+ _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature
84+ ) throws -> TypedHook < MethodSignature , HookSignature > {
85+ let hook = try prepareHook ( selector, methodSignature: methodSignature,
86+ hookSignature: hookSignature, implementation)
87+ try hook. apply ( )
88+ return hook
9089 }
9190
9291 /// Prepares a hook, but does not call apply immediately.
9392 @discardableResult public func prepareHook< MethodSignature, HookSignature> (
9493 _ selector: Selector ,
9594 methodSignature: MethodSignature . Type = MethodSignature . self,
9695 hookSignature: HookSignature . Type = HookSignature . self,
97- _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature ? )
98- throws -> TypedHook < MethodSignature , HookSignature > {
99- var hook : TypedHook < MethodSignature , HookSignature >
100- if let object = self . object {
101- hook = try ObjectHook ( object: object, selector: selector, implementation: implementation)
102- } else {
103- hook = try ClassHook ( class: `class`, selector: selector, implementation: implementation)
104- }
105- hooks. append ( hook)
106- return hook
96+ _ implementation: ( TypedHook < MethodSignature , HookSignature > ) -> HookSignature
97+ ) throws -> TypedHook < MethodSignature , HookSignature > {
98+ var hook : TypedHook < MethodSignature , HookSignature >
99+ if let object = self . object {
100+ hook = try ObjectHook ( object: object, selector: selector, implementation: implementation)
101+ } else {
102+ hook = try ClassHook ( class: `class`, selector: selector, implementation: implementation)
103+ }
104+ hooks. append ( hook)
105+ return hook
107106 }
108107
109108 /// Apply all stored hooks.
0 commit comments