gpt4 book ai didi

ios - 西奥斯 : Trying to take over UIView _subjectLine from CKContentEntryView in ChatKit

转载 作者:可可西里 更新时间:2023-11-01 03:38:18 25 4
gpt4 key购买 nike

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

我的主要问题是让编译器识别 _subjectLine作为一个有效的观点。如果我尝试对 _subjectLine 做任何事情/用它做任何事情,这就是我得到的结果:

Tweak.xm:8: error: ‘_subjectLine’ was not declared in this scope

我不知道如何声明一个已经存在的项目以在调整中使用。我在 Xcode 中使用的标准声明(通常在头文件中找到)似乎并不相同。

我已经用谷歌搜索了大约一个星期了。我发现的最常见的教程或信息只是简单地做:当方法激活时 - 显示警报。我可以做到,没问题。但是,我需要使用一个已经存在的对象。

最佳答案

在您的情况下,您似乎正在尝试使用您正在 Hook 的类的实例变量。修改实例变量在调整中不起作用。您必须使用 MSHookIvar 来“ Hook ”一个实例变量(又名 ivar)。示例:

[调整.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

MSHookIvar 还可以 Hook BOOL 和 float 等东西。

exampleVariableHooked = MSHookIvar<BOOL>(self, "_someBOOL");

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

因此,在您“ Hook ”变量之后,您可以更改它以满足您的需要。编码愉快!

关于ios - 西奥斯 : Trying to take over UIView _subjectLine from CKContentEntryView in ChatKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11918934/

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