检测卷何时安装在 OS X 上 [英] Detect when a volume is mounted on OS X

查看:20
本文介绍了检测卷何时安装在 OS X 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 OS X 应用程序需要响应正在安装或卸载的卷.

I have an OS X application that needs to respond to a volume being mounted or unmounted.

我已经通过定期检索卷列表并检查更改来解决此问题,但我想知道是否有更好的方法.

I've already solved this problem by retrieving the list of volumes periodically and checking for changes, but I'd like to know if there is a better way.

推荐答案

注册到你从[[NSWorkspace sharedWorkspace] notificationCenter]得到的通知中心,然后处理你感兴趣的通知.这些是卷相关的:NSWorkspaceDidRenameVolumeNotificationNSWorkspaceDidMountNotificationNSWorkspaceWillUnmountNotificationNSWorkspaceDidUnmountNotification.

Register to the notification center you get from [[NSWorkspace sharedWorkspace] notificationCenter] and then process the notifications you are interested in. These are the volume related ones: NSWorkspaceDidRenameVolumeNotification, NSWorkspaceDidMountNotification, NSWorkspaceWillUnmountNotification and NSWorkspaceDidUnmountNotification.

这篇关于检测卷何时安装在 OS X 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆