Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在启动主应用程序时启动Finder Sync扩展?_Objective C_Cocoa_Macos Sierra_Findersync - Fatal编程技术网

Objective c 如何在启动主应用程序时启动Finder Sync扩展?

Objective c 如何在启动主应用程序时启动Finder Sync扩展?,objective-c,cocoa,macos-sierra,findersync,Objective C,Cocoa,Macos Sierra,Findersync,在我的Cocoa应用程序中,我有一个finder sync扩展 启动应用程序时,我的finder sync扩展不会自动启动 我需要转到系统首选项->扩展并启用它 如何确保在启动主应用程序(.app)文件时启动并启用finder sync扩展名?签出 有一节在应用程序启动时重新启动FinderSyncExtension,说明如何在应用程序启动时重新启动FinderSyncExtension,从而使其更加可靠: + (void) restart { NSString* bundleID =

在我的Cocoa应用程序中,我有一个finder sync扩展

启动应用程序时,我的finder sync扩展不会自动启动

我需要转到系统首选项->扩展并启用它

如何确保在启动主应用程序(.app)文件时启动并启用finder sync扩展名?

签出

有一节在应用程序启动时重新启动FinderSyncExtension,说明如何在应用程序启动时重新启动FinderSyncExtension,从而使其更加可靠:

+ (void) restart
{
    NSString* bundleID = NSBundle.mainBundle.bundleIdentifier;
    NSString* extBundleID = [NSString stringWithFormat:@"%@.FinderSyncExt", bundleID];
    NSArray<NSRunningApplication*>* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:extBundleID];
    ASTEach(apps, ^(NSRunningApplication* app) {
        NSString* killCommand = [NSString stringWithFormat:@"kill -s 9 %d", app.processIdentifier];
        system(killCommand.UTF8String);
    });

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        NSString* runCommand = [NSString stringWithFormat:@"pluginkit -e use -i %@", extBundleID];
        system(runCommand.UTF8String);
    });
}
+(无效)重新启动
{
NSString*bundleID=NSBundle.mainBundle.bundleIdentifier;
NSString*extBundleID=[NSString stringWithFormat:@“%@.FinderSyncExt”,bundleID];
NSArray*应用程序=[NSRunningApplication runningApplicationsWithBundleIdentifier:extBundleID];
ASTEach(应用程序,^(NSRunningApplication*应用程序){
NSString*killCommand=[NSString stringWithFormat:@“kill-s 9%d”,app.processIdentifier];
系统(killCommand.UTF8String);
});
调度时间(调度时间(现在调度时间,(int64_t)(0.5*NSEC_/u秒)),调度获取主队列()之后进行调度^{
NSString*runCommand=[NSString stringWithFormat:@“pluginkit-e use-i%@”,extBundleID];
系统(runCommand.UTF8String);
});
}

问得好。。