Google自动填充功能在通话后崩溃

时间:2016-05-05 11:31:11

标签: ios swift google-maps google-places-api

我正在使用Google PlaceAutoComplete方法获取在textField中输入的Addess的建议。

 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)")
        }

    }

}

当我打电话给这个方法时。它崩溃了,说下面的错误。

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

我试图找到使用异常断点但不起作用。  可以有任何想法,我错了吗?

2 个答案:

答案 0 :(得分:1)

我已通过在App Transport安全设置中更正plist中的“允许任意加载”来解决此问题。我输入的是true,但它的类型是设置字符串而不是布尔

答案 1 :(得分:0)

某处某个NSDictionary被传递给代码,在那里它可以被解释为一个布尔值,例如NSString或NSNumber。我在您提供的代码中看不到类似的内容。如果异常断点不起作用,我会尝试在某处添加正常断点并逐步执行代码直到它崩溃。您还可以尝试删除某些部分和代码,看看崩溃是否仍然发生,这将让您缩小代码的哪些部分是责任。