AP.
AP.

Reputation: 5323

Detect when an ejectable device is (un)plugged in OS X

I am wondering how to be notified when a mass storage device is plugged (or unplugged) to the Mac.

Upvotes: 1

Views: 413

Answers (1)

Nicholas Riley
Nicholas Riley

Reputation: 44341

If you're writing a Cocoa app you can register for NSWorkspace notifications that fire when disks are mounted or unmounted.

At a lower level (more appropriate if you're writing a daemon or NSWorkspace doesn't give you enough information) you can use the Disk Arbitration Framework.

Upvotes: 4

Related Questions