简体   繁体   中英

Save array to Parse.com

I have a boolean array which contains 10 boolean values. I would like to save this array to Parse.com

There is an example on Parse.com, but when I try to save arrays it doesn't really seem to work:

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

Try this.

let myBooleanArray = [false,true,false,true,true,false]
let myObject = PFObject(className: "MyObject")
myObject["booleanArrayColumn"] = myBooleanArray
myObject.saveEventually()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM