你可以去:
/var/mobile/Applications/-safari app identifier-/Library/Safari/History.plist
为了找到Safari浏览器的完整路径(或任何其他系统/用户应用程序),你可以检查名为com.apple.mobile.installation.plist
的plist。该文件位于/var/mobile/Library/Caches/com.apple.mobile.installation.plist
。这个plist文件包含我们想要的。 plist中是一样的东西如下:
-Root
...
+System (Dictionary)
+User (Dictionary)
...
Safari是一个系统的应用使系统内的字典,我们可以看到一个名为com.apple.mobilesafari
关键这是一本字典的关键了。这本字典包含一个字符串键Path
这就是你想要的。正如你所看到的,通过了解应用程序类型和包标识符,可以知道任何其他应用程序的路径。所以,你的代码应该是这样的:
- (NSString*) safariPath {
return [self applicaitonFullPath:@"com.apple.mobilesafari" appType:@"System"];
}
- (NSString*) applicaitonFullPath:(NSString*)bundleIdentifier appType:(NSString*)appType {
//appType shoud be `System` or `User` case sensitive!!
NSDictionary *mobileInstallationDict = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Caches/com.apple.mobile.installation.plist"];
return mobileInstallationDict[appType][bundleIdentifier][@"Path"];
}
非常感谢Hamed,这是一个很好的解释和解决方案为我工作。 – user3932883 2014-10-09 07:10:39
不知道为什么我的更改被拒绝,但我仍然想提到bindleIdentifier应该是bundleIdentifier,而不是使用[type]键应该是[appType]。 – user3932883 2014-10-09 07:51:46
@ user3932883感谢您提到的修改。我纠正它们:) – Hamed 2014-10-10 12:51:59