keysInCircle
是字符串数组的名称,该字符串数组具有查询范围内用户的键。
postData
是tableView
用于填充视图的用户数组。
我的应用程序提供了一个线程! :每当我运行包含SIGABRT
的标签时,appdelegate
文件中的geofire
错误。
它也给出一个错误:
libc ++ abi.dylib:以类型为NSException的未捕获异常终止。
//Location Functions
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let _ : CLLocationCoordinate2D = manager.location?.coordinate else{
return
}
geoFire!.setLocation(locations.last!, forKey: Auth.auth().currentUser!.uid)
InRange(location: locations.last!)
for ids in keysInCircle{
fetchInformation(idlabel: ids)
}
}
func InRange(location:CLLocation){
var query = geoFire?.query(at: location, withRadius: 0.25)
query?.observe(.keyEntered, with: { (key, qloc) in
if(key != Auth.auth().currentUser?.uid && !self.keysInCircle.contains(key)){
self.keysInCircle.append(key)
}
})
query?.observeReady {
self.postData.removeAll()
}
}
func fetchInformation(idlabel:String){
let userDbRef:DatabaseReference = Database.database().reference().child("Users").child(idlabel)
userDbRef.observe(.value, with: { (snapshot) in
if let post:[String:Any] = snapshot.value as? Dictionary
{
let name = post["name"] as? String
var url = post["profileImageUrl"] as? String
if url == nil{
url = "default"
}
let id = snapshot.key
var college = post["college"] as? String
if college == nil{
college = "Other"
}
let tableUser = user(_objectId: id, _name: name!, _url: url!, _college: college!)
self.postData.append(tableUser)
self.tableView.reloadData()
}
})
}