- (BOOL) isJailbroken
{
BOOL isJailbroken = NO;
BOOL cydiaInstalled = [[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"];
FILE *f = fopen("/bin/bash", "r");
if (!(errno == ENOENT) && cydiaInstalled) {
isJailbroken = YES;
}
fclose(f);
return isJailbroken;
}
如果 f 为空(在真机调试时就会出现),则 fclose(f); 报错,需要改为 if (f) fclose(f);