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

问题描述

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

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

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

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]获得的通知中心然后处理您感兴趣的通知。这些是与卷相关的: NSWorkspaceDidRenameVolumeNotification NSWorkspaceDidMountNotification NSWorkspaceWillUnmountNotification NSWorkspaceDidUnmountNotification

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上装入卷的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:42