var users = [""] // This is a temporary Array for storing the data from Parse.
@IBOutlet var messageTableView: UITableView!
// The TableView will output the data in the array.
override func viewDidLoad() {
super.viewDidLoad()
var query = PFUser.query()
query!.findObjectsInBackgroundWithBlock({(objects:[AnyObject]?, error:NSError?) -> Void in
self.users.removeAll(keepCapacity: true)
//Delete Array Data..
for object in objects! {
var posts:PFUser = object as! PFUser
self.users.append(posts.username!)
//and append data to Array.
}
self.messageTableView.reloadData()}
My question :
This data is loaded from the "Users" class. But what I want is to load the data in the "posts" Class, what do you do? This is my first question raised in Stackoverflow. Please take care of me. : -) Haha
You're using a PFUser object instead of a PFQuery object.
From the parse documentation (link):
var query = PFQuery(className:"GameScore")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
println(object.objectId)
}
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}