I have a function in my xcode project in which I'd like to use some data that are on bitnami parse server.
In that function I'm creating a string array which I'd like to load up with my cloumn loc_names in classname Plocations.
My problem is when I calling this function above in my viewDidLoad() I get an empty array. How is that possible?
I was thinking about some kind of thread handling but I'm not sure.
func getParseLox() -> [String]{
var locName = ""
var locNames = [String]()
let query = PFQuery(className: "Plocations")
query.selectKeys(["loc_names"])
query.findObjectsInBackground { (objects, error) -> Void in
if let objects = objects {
for item in objects {
var anyu = item.object(forKey: "loc_names") as! String
print("anyu type:", type(of: anyu) )
print("anyu: ", anyu)
locNames.append(anyu)
print("locnames: ", locNames)
print("item: ", item.object(forKey: "locName") as! String)
}
locName = objects[0].object(forKey: "locName") as! String
print("these are the selectedKeys ", locName)
}
}
print("locNames array: ", locNames)
return locNames
}