每当我使用geofire提供线程时,应用程序就会崩溃! :SIGABRT错误

时间:2019-08-13 03:07:46

标签: ios swift firebase cllocationmanager geofire

keysInCircle是字符串数组的名称,该字符串数组具有查询范围内用户的键。

postDatatableView用于填充视图的用户数组。

我的应用程序提供了一个线程! :每当我运行包含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()
            }
    })
}

0 个答案:

没有答案