Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Swift2:初始化不可配置指针的正确方法<;非托管<;CFMutableDictionary>&燃气轮机;要传递给IORegistryEntryCreateCFProperties的参数_Macos_Swift_Swift2_Iokit - Fatal编程技术网

Macos Swift2:初始化不可配置指针的正确方法<;非托管<;CFMutableDictionary>&燃气轮机;要传递给IORegistryEntryCreateCFProperties的参数

Macos Swift2:初始化不可配置指针的正确方法<;非托管<;CFMutableDictionary>&燃气轮机;要传递给IORegistryEntryCreateCFProperties的参数,macos,swift,swift2,iokit,Macos,Swift,Swift2,Iokit,好的,在Swift 2中,IORegistryEntryCreateCFProperties的定义是 func IORegistryEntryCreateCFProperties(entry: io_registry_entry_t, _ properties: UnsafeMutablePointer<Unmanaged<CFMutableDictionary>?>, _ allocator: CFAllocator!, _ options: IOOptionBits)

好的,在Swift 2中,
IORegistryEntryCreateCFProperties
的定义是

func IORegistryEntryCreateCFProperties(entry: io_registry_entry_t, _ properties: UnsafeMutablePointer<Unmanaged<CFMutableDictionary>?>, _ allocator: CFAllocator!, _ options: IOOptionBits) -> kern_return_t
func IORegistryEntryCreateCFProperties(条目:io\u registry\u entry\u t,\u属性:UnsafeMutablePointer,\u分配器:CFAllocator!,\u选项:IOOptionBits)->kern\u return\t
我能行

var dict: UnsafeMutablePointer<Unmanaged<CFMutableDictionary>?> = nil
kr = IORegistryEntryCreateCFProperties(box as io_registry_entry_t, dict, kCFAllocatorDefault, nilOptions)
var dict:UnsafeMutablePointer=nil
kr=IORegistryEntryCreateCFProperties(框为io\U注册表项、dict、kCFAllocatorDefault、NILPOPTIONS)

它编译并运行。当然,它在执行
ioRegistryEntryCreateCProperties
时崩溃,因为
dict
被初始化为
nil
。我的问题是如何将
dict
初始化为非零值?我尝试过各种方法,但都没有成功。

类型的参数

UnsafeMutablePointer<Unmanaged<CFMutableDictionary>?>
Unmanaged<CFMutableDictionary>?
var props : Unmanaged<CFMutableDictionary>?
if IORegistryEntryCreateCFProperties(entry, &props, kCFAllocatorDefault, 0) == KERN_SUCCESS {
    if let props = props {
        let dict = props.takeRetainedValue() as NSDictionary
        print(dict)
    }
}