Sucharu Hasija
Sucharu Hasija

Reputation: 1136

Google Autocomplete function Crash after Call

I am using Google PlaceAutoComplete method to get suggestions of the Addess that is entered in textField.

 func placeAutocomplete(text:String)  {
            let placesClient = GMSPlacesClient()
            let filter = GMSAutocompleteFilter()
            filter.type = .Address

    placesClient.autocompleteQuery("New Delhi", bounds: nil, filter: nil) { (results, error) in
        guard error == nil else {
            print("Autocomplete error \(error)")
            return
        }

        self.addressArray.removeAll()
        for result in results! {


            self.addressArray.append(result.attributedFullText.string)
            print("Result \(result.attributedFullText.string) with placeID \(result.placeID)")
        }

    }

}

When i call this method. It crashes, say the Following error.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary boolValue]: unrecognized selector sent to instance 0x7fe338f01e40'

I have tried to found using exception breakpoint but doesn't work. Can any have idea, where i am wrong?

Upvotes: 10

Views: 824

Answers (2)

Sucharu Hasija
Sucharu Hasija

Reputation: 1136

I have resolved the issue by correcting in the plist for "allow arbitrary loads" in App Transport security Settings. I was typed it true but its type was set string instead for Boolean

Upvotes: 1

James Lambert
James Lambert

Reputation: 129

Somewhere a NSDictionary is being passed to the code where it is expecting a something that can be interpreted as a boolean such as an NSString or NSNumber. I don't see anything like that in the code you provided. If exception breakpoints aren't working I would try adding normal breakpoints somewhere and stepping over code until it crashes. You could also try removing certain sections and code and seeing if the crash is still happening, this will let you narrow down what portion of your code is to blame.

Upvotes: 0

Related Questions