Skip to content

Commit 9c82a2a

Browse files
authored
Update README.md
1 parent 9e387e1 commit 9c82a2a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Compare: [Swizzling a property without helper and with InterposeKit](https://gis
2222
Let's say you want to amend `sayHi` from `TestClass`:
2323

2424
```swift
25-
2625
class TestClass: NSObject {
2726
// Functions need to be marked as `@objc dynamic` or written in Objective-C.
2827
@objc dynamic func sayHi() -> String {
@@ -37,10 +36,9 @@ let interposer = try Interpose(TestClass.self) {
3736
methodSignature: (@convention(c) (AnyObject, Selector) -> String).self,
3837
hookSignature: (@convention(block) (AnyObject) -> String).self) {
3938
store in { `self` in
40-
41-
// You're free to skip calling the original implementation.
39+
4240
print("Before Interposing \(`self`)")
43-
let string = store.original(`self`, store.selector)
41+
let string = store.original(`self`, store.selector) // free to skip
4442
print("After Interposing \(`self`)")
4543

4644
return string + "and Interpose"
@@ -50,8 +48,11 @@ let interposer = try Interpose(TestClass.self) {
5048

5149
// Don't need the hook anymore? Undo is built-in!
5250
interposer.revert()
51+
```
5352

54-
// Want to hook just a single instance? No problem!
53+
Want to hook just a single instance? No problem!
54+
55+
```
5556
let hook = try testObj.hook(
5657
#selector(TestClass.sayHi),
5758
methodSignature: (@convention(c) (AnyObject, Selector) -> String).self,

0 commit comments

Comments
 (0)