【发布时间】:2020-03-26 17:56:49
【问题描述】:
我想在我的项目中保存和检索UIColor。我正在使用 Cloud-Firestore,我尝试过这样但它不起作用:
保存:
batch.setData(["textColor": "UIColor.white"], forDocument: listRef)
检索:
let textColor = documentData["textColor"] as! UIColor
但这给了我一个cast-error:
无法将“__NSCFString”(0x1de9b9a98)类型的值转换为“UIColor”(0x1de9ecd50)
正确的方法是什么?
【问题讨论】:
-
我解决它的方法是像@JustinM 在question 中建议的那样投射它。
标签: ios swift google-cloud-firestore uicolor