OC 属性
@property (nonatomic, strong) NSDictionary * _Nullable extraData;
swift使用 打印
Dictionary<AnyHashable, Any>
(lldb) po extraData ▿ Optional<Dictionary<AnyHashable, Any>> ▿ some : 2 elements ▿ 0 : 2 elements ▿ key : AnyHashable("localAddress") - value : "localAddress" - value : "江苏省无锡市锡山区厚桥街道厚安路无锡锡东科技产业园" ▿ 1 : 2 elements ▿ key : AnyHashable("virtual") - value : "virtual" - value : true
直接使用 下边代码会失败
if let dict = self.extraData as? [String:Any]{ }
应该使用
if let dict = self.extraData as? Dictionary<String, Any>{ let aVirtual = dict["virtual"] as? Bool ?? false let localAddress = dict["localAddress"] as? String ?? "" }
标签:extraData,OC,NSDictionary,value,localAddress,dict,let,swift From: https://www.cnblogs.com/qingzZ/p/18318196