How can I check whether a jailbreak exists? The easiest way is to check whether your device has a directory for jailbreak. The following is the code.
Detectdevice. h
View plaincopy to clipboardprint?
- @ Interface uidevice (helper)
- -(Bool) isjailbroken;
- @ End
@ Interface uidevice (helper)-(bool) isjailbroken; @ end
Detectdevice. m
View plaincopy to clipboardprint?
- @ Implementation uidevice (helper)
- -(Bool) isjailbroken {
- Bool jailbroken = no;
- Nsstring * cydiapath = @ "/applications/cydia. app ";
- Nsstring * aptpath = @ "/private/var/lib/APT /";
- If ([[nsfilemanager defaultmanager] fileexistsatpath: cydiapath]) {
- Jailbroken = yes;
- }
- If ([[nsfilemanager defaultmanager] fileexistsatpath: aptpath]) {
- Jailbroken = yes;
- }
- Return jailbroken;
- }
- @ End
@ Implementation uidevice (helper)-(bool) isjailbroken {bool jailbroken = no; nsstring * cydiapath = @ "/applications/cydia. APP "; nsstring * aptpath = @"/private/var/lib/APT/"; if ([[nsfilemanager defaultmanager] fileexistsatpath: cydiapath]) {jailbroken = yes ;} if ([[nsfilemanager defaultmanager] fileexistsatpath: aptpath]) {jailbroken = yes;} return jailbroken;} @ end
Then, call [uidevice currentdevice] isjailbroken] in your code. If yes is returned, the code is cracked. If no is returned, the Code is not cracked.