• IOS获取手机设备所有应用


    //返回一个数组
    1
    NSMutableArray *applist = [[NSMutableArray alloc]init]; 2 3 NSString *pathOfApplications = @"/var/mobile/Applications"; 4 // all applications 5 NSArray *arrayOfApplications = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplications error:nil]; 6 7 for (NSString *applicationDir in arrayOfApplications) { 8 9 // path of an application 10 NSString *pathOfApplication = [pathOfApplications stringByAppendingPathComponent:applicationDir]; 11 NSArray *arrayOfSubApplication = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplication error:nil]; 12 // seek for *.app 13 for (NSString *applicationSubDir in arrayOfSubApplication) { 14 if ([applicationSubDir hasSuffix:@".app"]) {// *.app 15 NSString *path = [pathOfApplication stringByAppendingPathComponent:applicationSubDir]; 16 path = [path stringByAppendingPathComponent:@"Info.plist"]; 17 // so you get the Info.plist in the dict 18 NSMutableDictionary *dict = [[NSDictionary dictionaryWithContentsOfFile:path]mutableCopy]; 19 // code to analyzing the dict. 20 dict[@"path"] = [pathOfApplication stringByAppendingPathComponent:applicationSubDir]; 21 if (ARRAY_NOT_EMPTY(dict[@"SBAppTags"])) { 22 NSArray *tags = dict[@"SBAppTags"]; 23 if ([tags containsObject:@"hidden"]) { 24 [dict autorelease]; 25 continue; 26 } 27 } 28 [applist addObject:dict]; 29 [dict release]; 30 31 } 32 } 33 } 34 35 return [applist autorelease];
  • 相关阅读:
    Xpath 和Css Selector使用
    JS 基础
    python中requests.session的妙用
    HTML基础之DOM
    吃着火锅唱着歌学会Docker
    SAAS方法论
    Python操作MySQL
    Flask中session实现原理
    人的成长永远不会大于自己的思想
    Serializers 序列化组件
  • 原文地址:https://www.cnblogs.com/wangshengl9263/p/3473579.html
Copyright © 2020-2023  润新知