hook ViewController 的时候xm文件报错:
Receiver type ‘ViewController’ for instance message is a forward declaration
如果在%hook前面声明ViewController则提示:
Cannot find interface declaration for ‘ViewController’; did you mean ‘UIViewController’?
/* --------------------------- */
在使用tweak hook ViewController没有出现类似问题
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface ViewController
@end
%hook ViewController
-(void)viewDidLoad{
[[self view] backgroundColor] = [UIColor redColor];
}
%end
试试这个 我确定 能不能用
我在使用 @interface 后面没有交()
有个小心得 也是大佬教的 能用 [ ] 的尽量不用 . 来实现
是ViewController 在MonkeyDev中会冒红
AiWmao
(Mao)
5
@interface ViewController : UIViewController
@end
谢谢前辈的指点问题解决了,的确是类的继承关系缺失导致的报错,奈何我浮躁愚笨,前辈们见笑了,感谢