Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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
这棵树是用Swift写的_Swift_Core Foundation - Fatal编程技术网

这棵树是用Swift写的

这棵树是用Swift写的,swift,core-foundation,Swift,Core Foundation,我不打算将以下内容转换成Swift: 静态CFTreeRef CreateMyTreeCFTypeRef根对象{ CFTreeContext-ctx; ctx.version=0; ctx.info=rootObject; ctx.retain=CFRetain; ctx.release=CFRelease; ctx.copyDescription=CFCopyDescription; 返回CFTreeCreateNULL,&ctx; } 我正在尝试使用以下代码设置上下文 let context

我不打算将以下内容转换成Swift:

静态CFTreeRef CreateMyTreeCFTypeRef根对象{ CFTreeContext-ctx; ctx.version=0; ctx.info=rootObject; ctx.retain=CFRetain; ctx.release=CFRelease; ctx.copyDescription=CFCopyDescription; 返回CFTreeCreateNULL,&ctx; } 我正在尝试使用以下代码设置上下文

let context = CFTreeContext(version: 1, info: nil, retain: CFRetain, release: CFRelease, copyDescription: CFCopyDescription)
但它不起作用


如何在Swift中创建和使用CFTree?

您可以尝试以下方法:

var info = "info"
let ctx = CFTreeContext(version: 0, info: &info, retain: nil, release: nil, copyDescription: nil)
let tree = CFTreeCreate(nil, [ctx])
let child1 = CFTreeCreate(nil, [ctx])
print(tree)

在CFTree内部禁用保留/释放是否正常工作?如果对象没有被ARC保留在其他地方,我会非常担心它会成为一个悬空的指针,因为CFTree不会保留它。