Google 调用后自动完成功能崩溃
Google Autocomplete function Crash after Call
我正在使用 Google PlaceAutoComplete 方法来获取在 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)")
}
}
}
当我调用这个方法时。它崩溃了,说以下错误。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary boolValue]: unrecognized selector sent to instance 0x7fe338f01e40'
我试图找到使用异常断点但不起作用。
谁能知道我哪里错了?
某处 NSDictionary 被传递给代码,它期望可以解释为布尔值的东西,例如 NSString 或 NSNumber。我在您提供的代码中没有看到类似的内容。如果异常断点不起作用,我会尝试在某处添加正常断点并跳过代码直到它崩溃。您也可以尝试删除某些部分和代码并查看崩溃是否仍在发生,这将让您缩小代码的错误范围。
我已通过更正应用传输安全设置中 "allow arbitrary loads" 的 plist 解决了这个问题。我输入的是 true 但它的类型设置为字符串而不是 Boolean
我正在使用 Google PlaceAutoComplete 方法来获取在 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)")
}
}
}
当我调用这个方法时。它崩溃了,说以下错误。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary boolValue]: unrecognized selector sent to instance 0x7fe338f01e40'
我试图找到使用异常断点但不起作用。 谁能知道我哪里错了?
某处 NSDictionary 被传递给代码,它期望可以解释为布尔值的东西,例如 NSString 或 NSNumber。我在您提供的代码中没有看到类似的内容。如果异常断点不起作用,我会尝试在某处添加正常断点并跳过代码直到它崩溃。您也可以尝试删除某些部分和代码并查看崩溃是否仍在发生,这将让您缩小代码的错误范围。
我已通过更正应用传输安全设置中 "allow arbitrary loads" 的 plist 解决了这个问题。我输入的是 true 但它的类型设置为字符串而不是 Boolean