【问题标题】:Cocoa Menu Bar Agent app With a Helper cocoa app and triggered ON from Main cocoa app, its Gone in NOT RESPONDINGCocoa 菜单栏代理应用程序使用 Helper cocoa 应用程序并从 Main cocoa 应用程序触发,其 Gone in NOT RESPONDING
【发布时间】:2017-09-14 07:46:56
【问题描述】:

这里我正在制作一个 Cocoa 菜单栏代理应用程序。现在问题是 Cocoa 主应用程序引用了另一个帮助程序应用程序,我使用 NSBundle 和工作区通过主应用程序打开(打开|关闭)按钮启动这个帮助程序应用程序。进入正常工作后 ​​2 分钟无响应。 在这种情况下,我们怎么能做到这一点。 辅助应用只是拖入主应用中。

开启按钮->

NSBundle *mainBundle = [NSBundle mainBundle];
NSString *helperAppPath = [[mainBundle bundlePath]
                               stringByAppendingString:@"/Contents/Resources/helperapp.app"];

[[NSWorkspace sharedWorkspace] launchApplication:helperAppPath];

Q.必须设置哪些权利或在哪个应用程序中? Q.Save It from crash(Not Responding).


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?

【问题讨论】:

    标签: macos cocoa helper


    【解决方案1】:

    实施答案 上面提到的代码用于少于 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];
    

    通过此代码,您的帮助应用程序可以正常启动,并且不会在不响应的情况下运行,谢谢欢迎。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      相关资源
      最近更新 更多