0

我在 theos 中进行了调整,需要查看一些变量的名称。

假设一个方法如下所示:

- (UILabel*)makeALabel {
    UILabel *name_that_i_want = [[UILabel alloc] init];
    [name_that_i_want setText:@"abcdefg"];
    return name_that_i_want;
}

当我查看此方法的标题时,我会看到:

-(id)makeALabel;

当我挂钩时,有没有办法让我转储在该方法中声明的变量?

-(id)makeALabel {
    %orig;
    //somehow get name of the label declared
    UILabel *label = MSHookIvar<UILabel *>(self, "name_that_i_want");
}
4

2 回答 2

1

不!

需要知道在函数或方法或对象中声明的变量的值表示设计不佳。它违背了面向对象编程的三个主要原则之一的封装。

于 2013-06-26T17:35:12.380 回答
0

答案是否定的。

您正在尝试做的事情可以通过更改您的需求设计,通过创建可以在方法中使用的 Class 和 ivars 来完成,只是为了替换局部变量。

然后您可以使用Objective-C Runtime访问类的 ivars/properties/methods。

于 2013-06-26T17:38:35.467 回答