-(void)awakeFromNib
NSArray* apps = [NSRunningApplication
runningApplicationsWithBundleIdentifier:@"com.apple.iTunes"];
if (apps && apps.count) {
for (NSRunningApplication *app in apps) {
[app forceTerminate];//强制关闭
}
}
[[[NSWorkspace sharedWorkspace] notificationCenter]addObserver:self selector:@selector(willLaunchApplication:) name:NSWorkspaceWillLaunchApplicationNotification object:nil];
}
- (void)willLaunchApplication:(NSNotification *)notify
{
NSDictionary *userInfo = notify.userInfo;
NSString *bundleIdentifier = [userInfo objectForKey:@"NSApplicationBundleIdentifier"];
if ([bundleIdentifier isEqualToString:@"com.apple.iTunes"]) {
for (NSRunningApplication *app in apps) {
[app forceTerminate];//强制关闭
}
}
}