【发布时间】:2019-03-05 13:10:54
【问题描述】:
我正在尝试保存一个
CLLocationCoordinate2Darray 进入 Firestore,但出现错误:
'FIRInvalidArgumentException',原因:'不支持的类型:NSConcreteValue'
而且我真的不知道我该怎么做。
在代码的顶部我有这个:
var locations: [CLLocationCoordinate2D] = []
然后点击“保存”按钮。我有这个代码:
//Document Reference properties
var _: DocumentReference = self.db
//Collection into Subcollection & Documents
.collection("rastad").document(authentication!)
.collection("promenad").addDocument(data:
//Insert first values
["Dog": txtfield_dog.text!,
"Person": txtfield_person.text!,
"What": txtfield_what.text!,
"Date": txtfield_Datum.text!,
"Time": txtfield_Time.text!,
"Timer": txtfield_timer.text!,
"Kilometers": txtfield_km.text!,
"Locations": locations
], completion: { (err) in
if err != nil
{
print("Error adding info-details")
return
}
else
{
print("Succeded!")
}
那么,我该如何解决这个问题呢?如何将 CLLocationCoordinate2D 数组插入 Firestore?而且,我以后怎样才能找回它?我真的很感激任何帮助!谢谢!
编辑:也许这个错误对你来说很清楚,但是很好。我不清楚,这就是我问这个问题的原因。如果我知道答案,我不会回答这个问题。而不是不喜欢并离开线程,您至少可以发表评论并告诉我不喜欢的原因。所以,我想我的问题会成立。
【问题讨论】:
-
错误很明显:Firestore 不支持
NSValue,这是CLLocationCoordinate2D的序列化类型。分别保存longitude和latitude或将坐标映射到CLLocationDegrees(又名Double)的数组。 -
而我究竟该怎么做..?对于所有不喜欢的人,至少写下原因。
标签: ios swift google-cloud-firestore cllocation cllocationcoordinate2d