Intercept method call in Objective-C

后端 未结 10 1421
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 13:34

Can I intercept a method call in Objective-C? How?

Edit: Mark Powell\'s answer gave me a partial solution, the -forwardInvocation

10条回答
  •  囚心锁ツ
    2020-12-02 14:15

    You can swizzle the method call with one of your own, which does whatever you want to do on "interception" and calls through to the original implementation. Swizzling is done with class_replaceMethod().

提交回复
热议问题