title: Unmount disk in OSX with DiskArbitration
body: <p>I'm trying to unmount a disk in OSX. The code works fine, but the callback is not called when the disk is unmounted successful only when it gives an error. I read the DiskArbitrationProgGuide and followed the steps, but no progress yet. Could someone give me a help?</p>
  
  <pre><code>@interface DriverUtilitiesController()
  
  void unmount_done(DADiskRef disk,
                    DADissenterRef dissenter,
                    void *context);
  
  @end
  
  + (void)umnountDrivePath:(NSString *)voulumePath
  {
      DASessionRef session = DASessionCreate(kCFAllocatorDefault);
  
      CFURLRef path = CFURLCreateWithString(NULL, (__bridge CFStringRef)voulumePath, NULL);
  
      DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault, session, path);
  
      DADiskUnmount(disk, kDADiskUnmountOptionDefault, unmount_done, NULL);
  
      CFRelease(disk);
  }
  
  #pragma mark - Unmount Callback
  
  void unmount_done(DADiskRef disk,
                    DADissenterRef dissenter,
                    void *context)
  {
  
      NSLog(@"Inside unmount_done");
  
      if (dissenter)
      {
          // Unmount failed. //
          NSLog(@"Unmount failed.");
  
      } else {
          NSLog(@"Unmounted Volume");
      }
  }
  </code></pre>
  
  <p><strong>Updating.</strong> Thanks to Ken Thomases the code now works</p>
  
  <pre><code>- (id)init
  {
      self = [super init];
  
      self.session = DASessionCreate(kCFAllocatorDefault);
  
      DASessionScheduleWithRunLoop(_session, [[NSRunLoop mainRunLoop] getCFRunLoop], kCFRunLoopDefaultMode);
  
      return self;
  }
  
  
  - (void)umnountDrivePath:(NSString *)voulumePath
  {
  
      CFURLRef path = CFURLCreateWithString(NULL, (__bridge CFStringRef)voulumePath, NULL);
  
      DADiskRef disk = DADiskCreateFromVolumePath(kCFAllocatorDefault, self.session, path);
  
      DADiskUnmount(disk, kDADiskUnmountOptionDefault, unmount_done, (__bridge void *)(self));
  
      CFRelease(disk);
  }
  
  void unmount_done(DADiskRef disk,
                    DADissenterRef dissenter,
                    void *context)
  {
      if (dissenter)
      {
          // Unmount failed. //
          NSLog(@"Unmount failed.");
  
      } else {
          NSLog(@"Unmounted Volume");
  
      }
  
      DriverUtilitiesController *driverUtilitiesController = (__bridge DriverUtilitiesController *)context;
  
  
      [driverUtilitiesController clearUnmountCallback];
  }
  
  - (void)clearUnmountCallback
  {
      DASessionUnscheduleFromRunLoop(_session, [[NSRunLoop mainRunLoop] getCFRunLoop], kCFRunLoopDefaultMode);
  
      CFRelease(self.session);
  }
  </code></pre>