Getting started with storing and retrieving data on parse

In 3 simple steps

MORE TUTORIALS

Pre-requisites

Import Framework

import Parse

Store Information

var gameScore = PFObject(className:"GameScore")
gameScore["score"] = 1337
gameScore["playerName"] = "Sean Plott"
gameScore["cheatMode"] = false
gameScore.saveInBackground {
  (success: Bool, error: Error?) in
  if (success) {
    // The object has been saved.
  } else {
    // There was a problem, check error.description
  }
}

Query Information

var query = PFQuery(className:"GameScore")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
  (objects: [PFObject]?, error: NSError?) -> Void in

  if error == nil {
    // The find succeeded.
    print("Successfully retrieved \(objects!.count) scores.")
    // Do something with the found objects
    if let objects = objects {
      for object in objects {
        print(object.objectId)
      }
    }
  } else {
    // Log details of the failure
    print("Error: \(error!) \(error!.userInfo)")
  }
}