0

Geofire を使用して、アイテムをその場所とともに保存しています。

特定のエリア内のアイテムを取得するために、Geofire の地理クエリを使用します。

 var queryHandle = query.observeEventType(.KeyEntered, withBlock: {(key: String!, location: CLLocation!) in
  println("Key '\(key)' entered the search area and is at location '\(location)'")
 })

結果は、予想どおり、指定された領域のキーです。私の質問は、実際のオブジェクトを取得して、残りのプロパティにアクセスできるようにするにはどうすればよいですか?

近くのオブジェクトをテーブルに表示したいので(後でマップに表示したいので)、UITableViewの一部としてすべてを行っています。

geofire を使用して UITableView を設定する際のベスト プラクティスも高く評価されます。

ありがとうございました!

4

1 に答える 1

0

値の単一イベントを作成して値を読み取るだけです。Firebase はそれを読み取るのに十分高速で効率的であり、これは UITableViews と UICollectionViews で問題なく動作します。


    //ref is the reference to your object's parent path, and key is the value you received with the geofire query
    ref.childByAppendingPath(key).observeSingleEventOfType(.Value, withBlock: {       
       (snapshot:FDataSnapshot!) in

        //The snapshot has the data of your actual object        

    })
于 2016-05-26T20:47:21.390 に答える