NSArray *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
NSLog(@"-apps----%@-----", apps);
if ([apps count] > 1)
{
NSRunningApplication *curApp = [NSRunningApplication currentApplication];
NSLog(@"-curApp----%@-----", curApp);
for (NSRunningApplication *app in apps)
{
NSLog(@"-app----%@-----", app);
if(app != curApp)
{
NSLog(@"-111----%@-----", app);
NSLog(@"-222----%@-----", curApp);
[app activateWithOptions:NSApplicationActivateAllWindows|NSApplicationActivateIgnoringOtherApps];
break;
}
}
[NSApp terminate:nil];
}
mac 检测相同app
最新推荐文章于 2024-03-24 22:11:05 发布