NSWorkspace
NSWorkspaceDidMountNotification
ディスクがマウントされると、通知が表示されます。概要では、通知ハンドラを宣言します。次に例を示します。
- (void) mountNotify:(NSNotification *)notification
{
// extract details from notification
NSDictionary *userInfo = notification.userInfo;
NSString *volumeMounted = userInfo[@"NSDevicePath"];
NSString *volumeDisplayName = userInfo[@"NSWorkspaceVolumeLocalizedNameKey"];
if (volumeMounted != nil)
{
// volume has been mounted
}
}
通知を登録します。
[[[NSWorkspace sharedWorkspace] notificationCenter]
addObserver:self
selector:@selector(mountNotify:)
name:NSWorkspaceDidMountNotification
object:nil
];
NSWorkspaceDidUnmountNotification
ディスクがアンマウントされたときの同様の通知もあります。
詳細については、Apple のNSWorkspace
ドキュメントを参照してください。
HTH。