Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DriverViewController: UIViewController {
- var placesArr : Array<Place> = []
- override func viewDidLoad() {
- super.viewDidLoad()
- self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
- var query = PFQuery(className:"places")
- query.whereKey("username", equalTo:"email@email.com")
- query.findObjectsInBackgroundWithBlock {
- (objects: [AnyObject]?, error: NSError?) -> Void in
- if error == nil {
- println("Successfully retrieved (objects!.count) scores.")
- if let objects = objects as? [PFObject] {
- for object in objects {
- let x = Place(aIdent: (object["Ident"] as! Int), aName: (object["name"] as! String), aAddress: (object["originAddress"] as! String), aCity: (object["originCity"] as! String), aCategoryName: (object["catName"] as! String), aLat: (object["aLat"] as! String), aLng: (object["aLng"] as! String))
- self.placesArr.append(x)
- println(placesArr) //****It works here and prints an array****
- }
- }
- } else {
- // Log details of the failure
- println("Error: (error!) (error!.userInfo!)")
- }
- }
- println(placesArr) //****But here it returns a blank array and this is where I need it to return an array****
- // Runs 1st
- query.findObjectsInBackgroundWithBlock {
- (objects: [AnyObject]?, error: NSError?) -> Void in
- // Runs 3rd
- }
- // Runs 2nd
- println(placesArr)
- var placesArray: [Place] = [] {
- didSet {
- // Do any execution that needs to wait for places array here.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement