Skip to content

Commit 7b13e6c

Browse files
committed
Reworked convenience methods on NSObject
1 parent e9c0a92 commit 7b13e6c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Sources/InterposeKit/NSObject+Interpose.swift

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import ObjectiveC
22

33
extension NSObject {
4+
5+
public func prepareHook<MethodSignature, HookSignature>(
6+
for selector: Selector,
7+
methodSignature: MethodSignature.Type,
8+
hookSignature: HookSignature.Type,
9+
build: @escaping HookBuilder<MethodSignature, HookSignature>
10+
) throws -> Hook {
11+
return try Interpose.prepareHook(
12+
on: self,
13+
for: selector,
14+
methodSignature: methodSignature,
15+
hookSignature: hookSignature,
16+
build: build
17+
)
18+
}
419

520
/// Installs a hook for the specified selector on this object instance.
621
///
@@ -43,13 +58,13 @@ extension NSObject {
4358
hookSignature: HookSignature.Type,
4459
build: @escaping HookBuilder<MethodSignature, HookSignature>
4560
) throws -> Hook {
46-
let hook = try Hook(
47-
target: .object(self),
48-
selector: selector,
61+
try Interpose.applyHook(
62+
on: self,
63+
for: selector,
64+
methodSignature: methodSignature,
65+
hookSignature: hookSignature,
4966
build: build
5067
)
51-
try hook.apply()
52-
return hook
5368
}
5469

5570
}

0 commit comments

Comments
 (0)