越獄後實現的功能

來源:互聯網
上載者:User

http://www.iloss.me/2011/11/03/%E8%8E%B7%E5%8F%96ios%E5%AE%89%E8%A3%85%E7%9A%84%E8%BD%AF%E4%BB%B6/

http://www.cnblogs.com/visen-0/archive/2011/08/22/2148847.html

http://www.iloss.me/2011/10/27/%E6%A3%80%E6%B5%8Biphone%E8%AE%BE%E5%A4%87%E6%98%AF%E5%90%A6%E8%B6%8A%E7%8B%B1/

首先,必須確定iPhone是越獄的,並且你的下面代碼啟動並執行目錄為/Applications/.

    NSFileManager* fileManager = [NSFileManager defaultManager];
    NSMutableArray* applist = [NSMutableArray arrayWithCapacity:10];
    for (NSString *path in [fileManager directoryContentsAtPath:@"/var/mobile/Applications"]) {
        for (NSString *subpath in [fileManager directoryContentsAtPath:
                                   [NSString stringWithFormat:@"/var/mobile/Applications/%@", path]]) {
            if ([subpath hasSuffix:@".app"])
            {
                NSString* infoplist =  [NSString stringWithFormat:@"/var/mobile/Applications/%@/%@/Info.plist", path, subpath];
                NSLog(@"sdfsadfa0%@",infoplist);
                NSDictionary* dict =  [NSDictionary dictionaryWithContentsOfFile:infoplist];
                NSLog(@"sdfsadfa1%@",dict);

                [applist addObject:[dict objectForKey:@"CFBundleDisplayName"]];
            }
        }

如何查看是否越獄?最簡單的方法就是查看你裝置上是否多了越獄的目錄

detectDevice.h
@interface UIDevice (Helper)  
- (BOOL)isJailbroken;  
@end &n
bsp;
detectDevice.m
@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

然後在你代碼中調用[UIDevice currentDevice] isJailbroken], 如果返回YES說明被破解了,為NO,則沒被破解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.