Skip to content

Issues creating mutable dictionary #744

Open
@pronebird

Description

@pronebird

Hi,

I am having issues constructing a mutable dictionary, maybe you could help me figure out what I am doing wrong:

static kIOPrimaryInterface: &str = "IOPrimaryInterface";

let property_dict = unsafe {
    CFMutableDictionary::new(
        kCFAllocatorDefault,
        0,
        &kCFTypeDictionaryKeyCallBacks,
        &kCFTypeDictionaryValueCallBacks,
    )
}.unwrap();

let primary_key = unsafe { CFString::from_static_str(kIOPrimaryInterface) };
let value  = unsafe { kCFBooleanTrue.unwrap() };

unsafe { property_dict.set(primary_key, value) };

Errors with:

34  |     unsafe { property_dict.set(primary_key, value) };
    |                            ^^^              ----- expected `&Opaque`, found `&CFBoolean`

note: expected `&Opaque`, found `CFRetained<CFString>`

34  |     unsafe { property_dict.set(primary_key, value) };
    |                                ^^^^^^^^^^^
    = note: expected reference `&objc2_core_foundation::opaque::Opaque`
                  found struct `CFRetained<CFString>`
    = note: expected reference `&objc2_core_foundation::opaque::Opaque`
               found reference `&CFBoolean`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frameworkAffects the framework crates and the translator for thembugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions