Inherits from NSObject
Declared in VolumeManager.h
VolumeManager.m

Overview

This class offers a high-level, Cocoa-style interface for DiskArbitration

VolumeManager offers similar functionality to the Disk Manager app or the diskutil command-line utility. It is possible to list all mounted volumes and manage both mounted and unmounted volumes or disks.

The delegate model is used to provide arbitration features to the delegate, allowing the delegate to approve or deny requests to mount or eject volumes. Additionally, the delegate’s notification methods are called when disks are pending mount, unmount, or eject, as well as after these events have taken place.

An example of these features is provided in the included “VolumeMgr” utility, which emulates the diskutil command-line utility.

To simply list all mounted volumes:

    VolumeManager *manager = [[VolumeManager alloc] init];
    NSArray *mounts = [manager mountedVolumes];

As documented below, it is possible to categorize mounted volumes by their “type” (bus or filesystem type). @see mountedVolumesByType and @see mountedVolumesForType:

Instance Methods

mountedVolumes

Asks for all currently mounted volumes

- (NSArray *)mountedVolumes

Return Value

Array of NSDictionary* instances, representing all mounted volumes

Discussion

Asks for all currently mounted volumes

Note: Each disks' NSDictionary* includes the VM-prefixed keys (see constants defined above).

Declared In

VolumeManager.h

mountedVolumesByType

Asks for all currently mounted volumes, organized by type

- (NSDictionary *)mountedVolumesByType

Return Value

Dictionary whose keys represent filesystem types, whose contents are arrays of NSDictionary* instances representing disks corresponding to the keyed type.

Discussion

Asks for all currently mounted volumes, organized by type

Note: Each disks' NSDictionary* includes the VM-prefixed keys (see constants defined above).

Declared In

VolumeManager.h

mountedVolumesForType:

Asks for all currently mounted volumes of the provided type

- (NSArray *)mountedVolumesForType:(NSString *)type

Return Value

An array of NSDictionary* instances representing disks corresponding to the provided type.

Discussion

Asks for all currently mounted volumes of the provided type

Note: Each disks' NSDictionary* includes the VM-prefixed keys (see constants defined above).

Declared In

VolumeManager.h

unmountAndEjectVolumeAt:withError:

Ejects the volume and all associated mounts that correspond to the given path

- (BOOL)unmountAndEjectVolumeAt:(NSURL *)URL withError:(NSError **)error

Parameters

URL

URL of the volume to eject.

error

Error to set if things go bad.

Return Value

Status of the request

Discussion

Ejects the volume and all associated mounts that correspond to the given path

Warning: The return code indicates whether or not the request was issued, not that the disk is ejected. The caller must implement the delegate method

See Also

Declared In

VolumeManager.h

unmountVolumeAt:withError:

Unmounts the volume at the given path

- (BOOL)unmountVolumeAt:(NSURL *)URL withError:(NSError **)error

Parameters

URL

URL of the volume to unmount.

error

Error to set if things go bad.

Return Value

Status of the request

Discussion

Unmounts the volume at the given path

Warning: The return code indicates whether or not the request was issued, not that the disk is unmounted. The caller must implement the delegate method

See Also

Declared In

VolumeManager.h