是否可以使用 cocoa 隐藏一个特定的应用程序?
我知道您可以使用以下代码隐藏所有其他应用程序
[[NSWorkspace sharedWorkspace] performSelectorOnMainThread:@selector(hideOtherApplications) withObject:NULL waitUntilDone:NO];
但是是否可以只隐藏一个特定的应用程序(例如 Safari)?
如果您的目标是 Mac OS 10.6+,则可以使用新的NSRunningApplication http://developer.apple.com/mac/library/documentation/AppKit/Reference/NSRunningApplication_Class/Reference/Reference.html class:
- (BOOL) hideAppWithBundleID:(NSString *)bundleID
{
NSArray *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:bundleID];
if ([apps count] == 0)
return NO;
return [(NSRunningApplication *)[apps objectAtIndex:0] hide];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)