是我%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.