简体   繁体   中英

Retrieving Array from Parse

I created an array that contains different numbers and each time the button is clicked the array advances to the next index number.

var currentNumber = 0 

var random = ["1", "2", "3", "4", "5", "6"]

@IBAction func numberUp(sender: UIButton) 

numberLabel.text = random[currentNumber]

++currentNumber

I tried to get similar results in with Parse but i couldn't. I created a class with a array in it

var numbers = PFObject(className:"Numbers")

numbers["number"] = ["1","2","3","4","5","6"]

numbers.save()

How would i go about doing the same thing but with the array i created on Parse. Or how could i retrieve the array from Parse and assign it to a local array ?

First you have to create a PFQuery like

let query = PFQuery(className: "Numbers")

Create a query to download the data in the table:

let result = query.find()

Then assume you have only one row in the table:

let arrayOfNumbers = result.first

Then you can iterate on arrayOfNumbers

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