Giter VIP home page Giter VIP logo

Comments (3)

gsdios avatar gsdios commented on July 19, 2024

无需了解实例本身如何设计,只要知道某个实例的selector即可hook。

from sdmagichook.

panxiaoqin avatar panxiaoqin commented on July 19, 2024

我这样写必定报错

    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.

gsdios avatar gsdios commented on July 19, 2024

TestClass.hookMethod() 表示是hook TestClass的类方法,在这里将TestClass看做一个类对象
aaa.hookMethod() 表示hook aaa这个实例拥有的实例方法
这正是实例维度hook的特点

from sdmagichook.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.