Search code examples
iossd-cardvolumemount

Enumerate mounted volumes on iOS


Following code works fine on MacOS, but return empty list on iOS with SanDisk «SanDisk iXpand» flash drive:

NSArray *keys = [NSArray arrayWithObjects:NSURLVolumeNameKey, NSURLVolumeIsRemovableKey, nil];
NSArray *urls = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:keys options:0];
NSLog(@«%@», urls); // print «null»
for (NSURL *url in urls) {
  NSError *error;
  NSNumber *isRemovable;
  NSString *volumeName;
  [url getResourceValue:&isRemovable forKey:NSURLVolumeIsRemovableKey error:&error];
  if ([isRemovable boolValue]) {
    [url getResourceValue:&volumeName forKey:NSURLVolumeNameKey error:&error];
    NSLog(@"%@", volumeName);
  }
}

Is there any way to get list of mounted volumes on iOS?


Solution

  • iOS doesn't support mounting volumes or accessing them, which is why you are not getting a list of mounted volumes.

    The iXpand device is accessed only through the SanDisk app.