Get a random word object. (swift, parse)

How do I get a random word object from a parse database. Any ideas? Any random word from the API's dictionary
Answered by Claude31 in 671922022

parse database

What do you mean, precisely ?
  • do you get a return from a request ?

  • which request ?

  • what is the return

  • you want to get a random of what exactly ?

Don't ask such general question on the forum:
  • explain what you want to achieve

  • post some initial code

  • explain what problem you are facing

Did you first look at Parse tutorials, to learn how to use ?
As an example: https ://guides.codepath. com/ios/Building-Data-driven-Apps-with-Parse

Then, if you have a query:
Code Block
query.findObjectsInBackground { (posts: [Post]?, error: Error?) in
if let posts = posts {
// do something with the array of object returned by the call
} else {
print(error?.localizedDescription)
}
}

you can get a random item in array with:
Code Block
if let randomPost = posts..randomElement() {
// Do what you need of this random value
}

Accepted Answer

parse database

What do you mean, precisely ?
  • do you get a return from a request ?

  • which request ?

  • what is the return

  • you want to get a random of what exactly ?

Don't ask such general question on the forum:
  • explain what you want to achieve

  • post some initial code

  • explain what problem you are facing

Did you first look at Parse tutorials, to learn how to use ?
As an example: https ://guides.codepath. com/ios/Building-Data-driven-Apps-with-Parse

Then, if you have a query:
Code Block
query.findObjectsInBackground { (posts: [Post]?, error: Error?) in
if let posts = posts {
// do something with the array of object returned by the call
} else {
print(error?.localizedDescription)
}
}

you can get a random item in array with:
Code Block
if let randomPost = posts..randomElement() {
// Do what you need of this random value
}

Get a random word object. (swift, parse)
 
 
Q