这里我正在制作一个可可菜单栏代理app.now,问题是Cocoa主应用程序引用了另一个Helper,我使用NSBundle和Workspace通过主应用程序启动了这个帮助程序,在正常工作后2 Min没有响应情况。在这种情况下,我们怎么能做到这一点呢?助手应用程序只是在主应用程序中拖动。
按钮上的->
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *helperAppPath = [[mainBundle bundlePath]
stringByAppendingString:@"/Contents/Resources/helperapp.app"];
[[NSWorkspace sharedWorkspace] launchApplication:helperAppPath];Q.which应享权利必须设置还是在哪个应用程序中?Q.Save从崩溃(没有响应)。
IMP Question is that -> .Note that NoW i watched at activity monitor there is showing debugserver919, in Parent Process. instead of launched1 tell me what i can do?发布于 2017-09-20 04:37:41
实现了答案,上面提到的代码用于比MacOS 10.6和10.6及以上的代码更少,我们可以使用代码
- (void)launchApplicationWithPath:(NSString *)path
{
// As recommended for OS X >= 10.6.
[[NSWorkspace sharedWorkspace] respondsToSelector:@selector(launchApplicationAtURL:options:configuration:error:)];
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:path isDirectory:NO] options:NSWorkspaceLaunchDefault configuration:nil error:NULL];
// For older systems.
// return [[NSWorkspace sharedWorkspace] launchApplication:path];
}以及如何调用此方法:
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *helperAppPath = [[mainBundle bundlePath]
stringByAppendingString:@"/Contents/Resources/helper.app"];
[self launchApplicationWithPath:helperAppPath];通过这段代码,你的助手应用程序启动得很好,没有反应,橡木,谢谢欢迎。
https://stackoverflow.com/questions/46213366
复制相似问题