在ios世界中有没有办法通过objective-c列出所有已安装的应用Info.plist文件?如果可能,如何读取每个Info.plist文件的属性?我使用下面的代码,但它只显示扫描开始和扫描结束。
- (void)scan
{
NSString *pathOfApplications = @"/var/mobile/Applications";
NSLog(@"scan begin");
// all applications
NSArray *arrayOfApplications = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplications error:nil];
for (NSString *applicationDir in arrayOfApplications) {
// path of an application
NSString *pathOfApplication = [pathOfApplications stringByAppendingPathComponent:applicationDir];
NSArray *arrayOfSubApplication = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplication error:nil];
// seek for *.app
for (NSString *applicationSubDir in arrayOfSubApplication) {
if ([applicationSubDir hasSuffix:@".app"]) {// *.app
NSString *path = [pathOfApplication stringByAppendingPathComponent:applicationSubDir];
path = [path stringByAppendingPathComponent:@"Info.plist"];
// so you get the Info.plist in the dict
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
// code to analyzing the dict.
}
}
}
NSLog(@"scan end");
}
来源:link