我需要以编程方式为非越狱的iOS设备获取所有已安装应用程序的版本。
有可能实现这一目标吗?
最佳答案
有可能,请尝试以下代码。
Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];
for (LSApplicationProxy *apps in [workspace performSelector:@selector(allApplications)])
{
NSString *localizedName = apps.localizedName;
if([apps.applicationType isEqualToString:@"User"])
{
NSLog(@"\nlocalizedName: %@",localizedName);
NSLog(@"minimumSystemVersion: %@",apps.minimumSystemVersion);
NSLog(@"fileSharingEnabled: %d",apps.fileSharingEnabled);
NSLog(@"sdkVersion: %@",apps.sdkVersion);
NSLog(@"teamID: %@",apps.teamID);
}
}
为此,您需要在您的应用中放置4个类:
LSApplicationWorkspace, LSResourceProxy, LSBundleProxy, LSApplicationProxy.
关于objective-c - 以编程方式列出iOS设备中安装的所有应用程序的版本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34849051/