Comments (3)
无需了解实例本身如何设计,只要知道某个实例的selector即可hook。
from sdmagichook.
我这样写必定报错
let imp: @convention(block) (TestClass, Int32,Int32) -> Int32 = { (vc, a,b) in
vc.callOriginalMethod {
vc.sub(a, value: b)
}
return 10
}
let hookID = TestClass.hookMethod(#selector(TestClass.sub(_:value:)), impBlock: imp)
let aaa = TestClass()
let c = aaa.sub(1, value: 2)
print(c)
必须改成
let hookID = aaa.hookMethod(#selector(TestClass.sub(_:value:)), impBlock: imp)
sub 不是静态方法
from sdmagichook.
TestClass.hookMethod() 表示是hook TestClass的类方法,在这里将TestClass看做一个类对象
aaa.hookMethod() 表示hook aaa这个实例拥有的实例方法
这正是实例维度hook的特点
from sdmagichook.
Related Issues (14)
- 您这个和Aspects的instance hook有什么不同吗😂 HOT 7
- 使用这个库,影响上架吗 HOT 1
- 用于打点, 如何Hook所有继承某个类的实例函数,而不是仅仅某一个实例的函数 HOT 1
- iOS 14.5崩溃 HOT 3
- release环境 最新iOS15多的系统 卡主了
- SDOrderedDict 这个类的命名有点不合适
- 这个库功能跟aspects基本一样,只有api上有细微差点……建议写相关功能先调研一下相关的库,避免重复造轮子 HOT 1
- SDMagicHook与Aspects的异同 HOT 3
- demo0 KVO crash HOT 3
- 代码应该在哪里编写 HOT 2
- swift 调用 请检查你是否在hook了 `pointInside:withEvent:` 方法之后忘记调用原始方法。 HOT 1
- hook方法后,不调用以前hook的方法崩溃 HOT 2
- Crash Issue HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdmagichook.