通过内存地址替换方法
我想知道是否有任何方法可以通过内存地址来混合方法。 例如: 我有一个指向方法 0xFFFFFF 的指针。 我的应用程序中有一个方法。 我想用我的方法替换指针。有没有办法可以在 Objective-C 中替换这个指针。谢谢。
I was wondering if there was any way to swizzle a method by a memory address.
For example:
I have a pointer to a method 0xFFFFFF.
I have an method in my application.
I want to replace the pointer with the my method. Is there way that I could replace this pointer in Objective-C. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你说的是注射。
看看 mach_inject
以及mach_inject。 com/StarProject/StarRuntime" rel="nofollow">Starruntime
和应用程序增强器。
You are talking about injection.
Take a look at mach_inject
also Starruntime
and Application Enhancer.
您正在寻找
method_setImplementation(Method m, IMP imp)
不过,您必须首先使用
class_getInstanceMethod
或class_getClasssMethod
解析选择器的方法>You're looking for
method_setImplementation(Method m, IMP imp)
You have to have resolved the Method for your selector first though, using
class_getInstanceMethod
orclass_getClasssMethod
您可以使用“performSelector”:
选择器可以存储在变量中。
You could use "performSelector":
The selector can be stored in a variable.