gpt4 book ai didi

swift - 将 UnsafeMutablePointer 转换为 [String :AnyObject]

转载 作者:搜寻专家 更新时间:2023-11-01 05:38:38 24 4
gpt4 key购买 nike

我已经将 [String:AnyObject] 作为用户数据传递给 addToolTipRect..

var myObject = [String:AnyObject]()

self.addToolTipRect( binCoordinates, owner: self, userData: &myObject )

因此,在 stringForToolTip 中,我需要将其转换回 [String:AnyObject]

var theData = [String:AnyObject](data) 不起作用。

最佳答案

// userData: UnsafeMutablePointer<Void>

let pUserData = UnsafeMutablePointer<Dictionary<String,AnyObject>>(userData)

// you can accsees all properties and functions via

pUserData.memory.myPropery // read or write myObject.myProperty
pUserData.memory.foo() // execute myObject.foo()

关于swift - 将 UnsafeMutablePointer 转换为 [String :AnyObject],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33761857/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com