gpt4 book ai didi

ios - Theos实例方法调用

转载 作者:行者123 更新时间:2023-11-28 22:16:04 27 4
gpt4 key购买 nike

我已经搜索过这个问题的答案,但找不到。

我如何在我的 Theos tweak 中 Hook 的同一个类中调用实例方法?如果我使用的是标准 Xcode,我会使用 self 方法,即-

[self method:arg];

但在 theos 调整中,这表示无法找到该方法,即使我 Hook 该方法也是如此。

示例:

%hook classimhooking

-(void)methodimhooking
{
[classimhooking methodiwanttocall];
[self methodiwanttocall];
%orig;
}

-(void)methodiwanttocall
{
%orig;
}

%end

methodiwanttocall 在那里,我可以 Hook 它,只是不调用它。我尝试用 %new 添加一个新方法并调用它,但没有找到,我也尝试过延迟,但没有找到。我试过定义我的类的一个变量并调用它,但它不起作用。

我还看到您可以直接获取 iVar,但这不适用于方法。

如有任何想法,我们将不胜感激。

最佳答案

如果你想在你刚刚 Hook 的对象上调用一个方法,你可以使用performSelector (或者 performSelector:withObject: 如果它有一个参数),它应该是这样的:

[self performSelector:@selector(methodiwanttocall)];

关于ios - Theos实例方法调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21645020/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com