mountedVolumeURLsIncludingResourceValuesForKeys :options:
Returns an array of URLs that identify the mounted volumes available on the computer.
- (NSArray *)mountedVolumeURLsIncludingResourceValuesForKeys:(NSArray *)propertyKeys options:(NSVolumeEnumerationOptions)options
Parameters
- propertyKeys
- An array of keys that identify the file properties that you want pre-fetched for each volume. For each returned URL, the values for these keys are cached in the corresponding
NSURL
objects. You may specifynil
for this parameter. For a list of keys you can specify, seeCommon File System Resource Keys
. - options
- Option flags for the enumeration. See “Mounted Volume Enumeration Options.”
Return Value of [NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys]
An array of
NSURL
objects identifying the mounted volumes.Discussion
This call may block if I/O is required to determine values for the requestedpropertyKeys.
Example of [NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys]
NSArray *keys = [NSArray arrayWithObjects:NSURLVolumeNameKey, NSURLVolumeURLForRemountingKey, NSURLVolumeIsEjectableKey, NSURLVolumeIsRemovableKey, nil];
NSArray *urls = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:keys options:0];
for (NSURL *url in urls)
{
NSError *error;
NSNumber *isRemovable;
NSString *volumeName;
[url getResourceValue:&isRemovable forKey:NSURLVolumeIsRemovableKey error:&error];
[url getResourceValue:&volumeName forKey:NSURLVolumeNameKey error:&error];
NSLog(@"Standard Device : %@ - Removable: %c", volumeName, [isRemovable boolValue]);
}