Theos:试图从ChatKit中的CKContentEntryView接管UIView _subjectLine

Cal*_*rie 6 jailbreak ios

我试图控制消息应用程序中的主题行.现在我只想在主题字段中显示文本.

我遇到的主要问题是让编译器识别_subjectLine为有效视图.如果我尝试对/做任何事情,这就是我得到的_subjectLine:

Tweak.xm:8: error: ‘_subjectLine’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

我不知道如何声明在调整中使用的现有项目.我在Xcode中使用的标准声明(通常在头文件中找到)似乎不起作用.

我一直在谷歌上搜索一周左右.我发现最常见的教程或信息就是简单:当方法激活时 - 显示警报.我能做到,没问题.但是,我需要使用已存在的对象.

s6l*_*A3I 10

在您的情况下,您似乎正在尝试使用您正在挂钩的类的实例变量.修改实例变量在调整中不起作用.您必须使用MSHookIvar来"挂钩"实例变量(也称为ivar).例:

[Tweak.xm/mm]的

#import <substrate.h> // necessary
#import <Foundation/Foundation.h>

@interface TheClassYouAreHooking : NSObject {
    NSString *_exampleVariable;
}
- (void)doSomething;
@end

NSString *_exampleVariableHooked;

%hook TheClassYouAreHooking
- (void)doSomething 
{
    // 'Hook' the variable

    exampleVariableHooked = MSHookIvar<NSString *>(self, "_exampleVariable");

    // The name of the hooked variable does not need to be the same

    exampleVariableHooked = @"Hello World";

    // You can do ANYTHING with the object Eg. [exampleVariableHooked release];

}
%end
Run Code Online (Sandbox Code Playgroud)

MSHookIvar也可以挂钩BOOL和浮点数等东西.

exampleVariableHooked = MSHookIvar<BOOL>(self, "_someBOOL");
Run Code Online (Sandbox Code Playgroud)

它在substrate.h中声明,因此您需要导入,否则您将无法编译您的调整.另外作为奖金提示,我只是提醒你,你必须在你的tweakname.plist中放置你正在挂钩的应用程序/框架的标识符.

因此,在您"挂钩"变量后,您可以根据自己的需要进行更改.快乐的编码!