Tweak %new出来的方法,怎么在原对象的方法里怎么调用?

是我%new用错了还是调用方法错了?
Tweak.xm


%hook AddressBookFriendViewController 

- (void)initView{
    NSLog(@"initView befor: %d", (NSUInteger)[self hookListCount]);
    %orig;
    NSLog(@"initView after: %d", (NSUInteger)[self hookListCount]);
}
- (void)onAddContact{
    NSLog(@"onAddContact befor: %d", (NSUInteger)[self hookListCount]);
    %orig;
    NSLog(@"onAddContact after: %d", (NSUInteger)[self hookListCount]);
}
- (void)onContactsItemViewRightButtonClick:(id)arg1{
    NSLog(@"onContactsItemViewRightButtonClick: %@",arg1);
    %orig;
}

%new
-(NSUInteger)hookListCount{
    NSMutableArray *array = MSHookIvar<NSMutableArray *>(self, "m_arrAddressBookFriendList");
    return array.count;
}

%end

编译时报错:

Compiling Tweak.xm...
Tweak.xm:5:52: error: instance method '-hookListCount' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
    NSLog(@"initView befor: %d", (NSUInteger)[self hookListCount]);
                                                   ^~~~~~~~~~~~~
Tweak.xm:4:8: note: receiver is instance of class declared here
@class AddressBookFriendViewController; 
       ^
Tweak.xm:7:52: error: instance method '-hookListCount' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
    NSLog(@"initView after: %d", (NSUInteger)[self hookListCount]);
                                                   ^~~~~~~~~~~~~
Tweak.xm:4:8: note: receiver is instance of class declared here
@class AddressBookFriendViewController; 
       ^
Tweak.xm:10:56: error: instance method '-hookListCount' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
    NSLog(@"onAddContact befor: %d", (NSUInteger)[self hookListCount]);
                                                       ^~~~~~~~~~~~~
Tweak.xm:4:8: note: receiver is instance of class declared here
@class AddressBookFriendViewController; 
       ^
Tweak.xm:12:56: error: instance method '-hookListCount' not found (return type
      defaults to 'id') -Werror,-Wobjc-method-access]
    NSLog(@"onAddContact after: %d", (NSUInteger)[self hookListCount]);
                                                       ^~~~~~~~~~~~~
Tweak.xm:4:8: note: receiver is instance of class declared here
@class AddressBookFriendViewController; 
       ^
4 errors generated.

你要把%new出来的方法也定义到头文件里去

tweak里要hook的类的头文件该怎么修改呢?书里theos章节里没找到,求详细说一说

在你自己的头文件里加上

@interface AddressBookFriendViewController
- (NSUInteger)hookListCount;
@end

我试过加在头文件,编译通过,运行直接报错,提示nrecognized selector sent to instance 0x17b99c00,能解答一下吗?

在自己的头文件中这样添加方法会不会覆盖原来头文件中的方法?

[self 方法名]

声明一下,跟C++里的@class作用类似