0

In my program I'm using DiskArbitration to check some values against a database and, if certain conditions happen, do something before it mounts. I'm using DARegisterDiskPeekCallback with this callback:

DARegisterDiskPeekCallback(diskSession, kDADiskDescriptionMatchVolumeMountable, 0, determineIfNewDisk, NULL);

void determineIfNewDisk(DADiskRef disk, void* context)
{
    NSDictionary *diskProps = (__bridge NSDictionary *)DADiskCopyDescription(disk);
    CFUUIDCreateString(nil, *(CFUUIDRef *)diskProps[@"DAVolumeUUID"]);
}

I'd like to be able to use the UUID and get a string to check in the database, but since diskProps[@"DAVolumeUUID"] returns a generic pointer rather than a CFUUIDRef pointer, it won't allow me to run CFUUIDCreateString(). I attempted to cast the pointer above to a CFUUIDRef pointer, but I get this error: Cast of an Objective-C pointer to 'CFUUIDRef *' ... is disallowed by ARC. If I don't attempt to cast, CFUUIDCreateString will not accept the pointer.

Is there a way to either a) cast the pointer to a CFUUIDRef pointer, or b) get the string of the UUID?

josh
  • 9,656
  • 4
  • 34
  • 51

1 Answers1

3

Use this code instead:

CFUUIDCreateString(nil, (CFUUIDRef)diskProps[@"DAVolumeUUID"]);
trojanfoe
  • 120,358
  • 21
  • 212
  • 242