【发布时间】:2014-01-12 03:39:21
【问题描述】:
如果我想让应用程序运行命令来检查设备是否越狱,我该怎么做?
(如果程序可以确定是否安装了Cydia,这是我要执行的命令)
UIAlertView *jailbreakDetection = [[UIAlertView alloc]
initWithTitle:@"Jailbreak Detected"
message:@"This application will not run while a jailbreak is installed."
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
[jailbreakDetection show];
通过显示此警报,用户无法运行应用程序,因为无法阻止消息显示在屏幕上。我研究了一些类似的问题,但没有一个对我有用,例如,当我运行此代码时,出现错误“预期标识符或'('”。我在 NavigationController.m 文件中运行它,这样我就会在初始应用程序启动时点击用户。
NSString *filePath = @"/Applications/Cydia.app";
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
UIAlertView *jailbreakDetection = [[UIAlertView alloc]
initWithTitle:@"Jailbreak Detected"
message:@"This application will not run while a jailbreak is installed."
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
[jailbreakDetection show];
}
我做错了什么?我应该把它放在一个单独的文件中吗?
【问题讨论】:
-
您不只是检查一下您是否可以以root身份执行某些操作。
-
"Expected identifier or '('" 是编译器错误,所以你会在构建你的应用程序时得到它,而不是在运行它时。但实际上你的代码似乎可以编译很好。你到底是从哪里得到错误消息的?
-
需要注意的是,越狱不等于盗版。禁止所有越狱用户可能会适得其反
-
@coneybeare:这只是一种展示概念证明的方式,而不是可能实际使用的东西。
标签: ios objective-c xcode5 jailbreak