【发布时间】:2014-04-25 01:18:49
【问题描述】:
我对越狱 iOS 调整开发非常陌生,并且有一个问题。每当从 Springboard 打开应用程序时,我都会按照教程进行提示。调整代码是:
#include <UIKit/UIKit.h>
@interface SBApplicationIcon
- (void)launchFromLocation:(int)arg;
- (id)displayName;
@end
%hook SBApplicationIcon
-(void)launchFromLocation:(int)location{
NSString *appName = [self displayName];
NSString *message = [NSString stringWithFormat:@"Application launched: %@", appName];
UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:appName message:message delegate:nil cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
[myAlert show];
%orig;
}//end function
%end
这个调整代码工作得很好。我不明白这是如何工作的。查看SBApplicationIcon的头文件,没有-(void)launchFromLocation:(int)location;
这样的方法经过一些研究,虽然我发现 SBIcon 类头有这个确切的函数定义。如果我将代码更改为:
#include <UIKit/UIKit.h>
@interface SBIcon
- (void)launchFromLocation:(int)arg;
- (id)displayName;
@end
%hook SBIcon
-(void)launchFromLocation:(int)location{
NSString *appName = [self displayName];
NSString *message = [NSString stringWithFormat:@"Application launched: %@", appName];
UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:appName message:message delegate:nil cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
[myAlert show];
%orig;
}//end function
%end
警报视图不会出现,并且该函数永远不会被调用!我觉得这是一个愚蠢的问题,但我根本不明白这是如何工作的。有人可以向我解释一下吗?我正在使用 iOS7 标头和 iOS7 iPhone。
谢谢!
【问题讨论】:
-
你错了。不是一个愚蠢的问题:)
-
好问题。但是,我不知道您是否启用了 ARC,但如果您没有启用,请不要忘记 [myAlert release]; !
标签: ios ios7 hook jailbreak theos