ios - Query class in Parse (swift) -


i have strange issue. following block of code placed in viewdidappear section of first view controller, , when runs, println(latarray), println(longarray), println(addressarray), return no value. in console returns [] 3 arrays. however, when go view controller, , go back, populate data parse. why this? why wont latarray, longarray, , addressarray populate when app loaded first time viewwillappear method?

    var query = pfquery(classname: "newlog")      // add clause if there search criteria     query.wherekey("type", containsstring: newrecordcreated)      println(query)      query.findobjectsinbackgroundwithblock({         (objects, error) -> void in         if error == nil {             // results found             if let objects = objects as? [pfobject] {                 object in objects {                     //println(object["follower"])                     latarray.append(object["lat"] as! double)                     longarray.append(object["long"] as! double)                     addressarray.append(object["address"] as! string)                 }             }             // self.tableview.reloaddata()         } else {             println("error")             // network inaccessible , have no cached data             // query.         }     })      println(latarray)     println("^^latitude values")     println(longarray)     println("^^longitude values")     println(addressarray)     println("^^address values") } 

the query being executed in background. code in block (closure) executed when query finished. note: might , after viewdidappear finishes. if put print statements after loop, should see values. if uncomment reloaddata method, table should updated new information when query finishes.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -