NSMutableArray *defaultWorkspaceApps =[[NSClassFromString(@“LSApplicationWorkspace”) defaultWorkspace] applicationsOfType:0];
for (LSApplicationProxy *app in defaultWorkspaceApps) {
if([app.bundleIdentifier containsString:@“com.my.bundleIdentifier”])
{
NSURL * resourcesDirectoryURL = [app performSelector:NSSelectorFromString(@“containerURL”)];
NSString* path=[resourcesDirectoryURL absoluteString];
path=[str stringByReplacingOccurrencesOfString:@“file://” withString:@“”];//路径
}
}
这段代码在Objective-C中遍历LSApplicationWorkspace中的应用,查找bundleIdentifier包含'com.my.bundleIdentifier'的应用,并获取其资源目录URL,然后转换为不包含'file://'的路径。
1435

被折叠的 条评论
为什么被折叠?



