1

I have the following code and I seem to have this error that says "type 'NSObject' has no subscript members" in the following code I have the same error on the lines that say

let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue

            let longitude = NSString(string: places[activePlace]["lon"]!).doubleValue 

as well as the line that says

annotation.title = places[activePlace]["name"]

this is very weird as I have used this same piece of code in other apps and haven't had any trouble until this one. I have also looked up other questions but haven't found a solution

here is the full bit of code:

else {

            let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue

            let longitude = NSString(string: places[activePlace]["lon"]!).doubleValue

            let coordinate = CLLocationCoordinate2DMake(latitude, longitude)

            let latDelta:CLLocationDegrees = 0.01

            let lonDelta:CLLocationDegrees = 0.01

            let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)

            let region:MKCoordinateRegion = MKCoordinateRegionMake(coordinate, span)

            self.Map.setRegion(region, animated: true)

            let annotation = MKPointAnnotation()

            annotation.coordinate = coordinate

            annotation.title = places[activePlace]["name"]

            self.Map.addAnnotation(annotation)


        }

How could I get ride of this issue that seems to be all over my code?

thanks !

update 'places' is defined like this

var places = [PFUser(className: "spot"),Dictionary<String,String>()]
stephen D
  • 255
  • 1
  • 5
  • 16

0 Answers0