Question

I'm trying to intercept when iTunes starts up on Mac OS X, so I can relaunch my application to work around few bugs in the iTunes Framework.

What I did is to temporarly disable the sandboxing of my application and listen to all NSDistributedNotificationCenter notifications in order to examine them and pick the ones I want.

What I found is that upon start iTunes apparently sends this event:

object: com.apple.iTunes.help name: HelpBookRegistrationDidChange userInfo: (null)

which seems rather unique but also doesn't give an exact clue it is related to a startup event only at 100%.

Does anyone know if this is safe way to intercept such event?

If so, once my app is sandboxed again I need to ask temporary permission to listen to this kind of event, how can I do that in code?

Do you believe scripting bridge can help in this case?

Was it helpful?

Solution

You don't need to disable sandboxing for this, just observe NSWorkspaceDidLaunchApplicationNotification in the notification center provided by NSWorkspace, not the distributed one.

You'll get an instance of NSRunningApplication in the user info of the notification, which you can use to determine whether the launched app was iTunes (use the bundleIdentifier property).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top