BENQ
BENQ

Reputation: 93

Query objects From Parse localDataStore

I'm busy trying to query items I'm storing im my Parse localDataStore. There is 6 fields that I'm storing in my LocationLogs class (Parse class)/. These fields are image, Lat, long, altitude, title, description. When storing them directly into Parse via

    locationLogs["longitude"] = location.longitude
    locationLogs["latitude"] = location.latitude
    locationLogs["altitude"] = altitude
    locationLogs.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
    if (success) {

        }else{

        }
    }

It works perfectly. But when using locationLogs.pinInBackground() and then trying to query it with

 let query = PFQuery(className:"LocatinLogs")
    query.fromLocalDatastore()
    query.findObjectsInBackgroundWithBlock( { (NSArray results, NSError error) in
        // do something

        println("count = \(results!.count)")

    })

The count stays = nil.

What query method must I use? The template code Parse.com provides gives an Error for the block.

Upvotes: 2

Views: 61

Answers (2)

000
000

Reputation: 225

I think you made a spelling Error:

  let query = PFQuery(className:"LocatinLogs")

The Class that you query is Spelt wrong. That will fix your error (: It happens to the best of us trust me!!

Upvotes: 1

Wain
Wain

Reputation: 119031

Save the object and pin it on success. Until an object is saved (or pushed to saveEventually IIRC) it doesn't have an objectId and isn't considered as a 'valid' object (for instance you also can't add it to a relationship).

Upvotes: 0

Related Questions