简体   繁体   中英

Create string from DiskArbitration CFUUID object

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?

请改用以下代码:

CFUUIDCreateString(nil, (CFUUIDRef)diskProps[@"DAVolumeUUID"]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM