stephen D stephen D - 5 months ago 10
Swift Question

Why do I get a "Value of type 'TableViewController' has no member 'place' ''?

I am tying to download some data from parse (a string) and I get the error

"Value of type 'TableViewController' has no member 'place'
on the line that says :

self.place.append(spotdetail.name!)


I have this as a global var :

var place = [""]


and this is my code in the ViewDidLoad:

let query = PFObject.query()
query!.findObjectsInBackgroundWithBlock ({ (objects, error) in

if let skateparks = objects {

for object in skateparks {

if let spotdetail = object as PFObject! {

self.place.append(spotdetail.name!)

self.tableView.reloadData()


}

}

}

print(place)

})


What can I change to make it work as I don't understand why it doesn't recognize the
var place
as it is in the same view controller (tableView)

thanks!

Answer

Everywhere in closure you should use self keyword for properties:

print(self.place)
Comments