swift - 如何在 NsmutableArray 中快速获取 google 地点 id?

标签 swift google-maps nsmutablearray mapkit

我想从 google place API 中提取地点 ID 这是示例代码

 for result in results! {
            if let result = result as? GMSAutocompletePrediction {
                print("Result \(result.attributedFullText) with placeID \(result.placeID)")

                self.placeId.addObject(result.placeID)
                print("placeId==\(self.placeId)")

      //          self.placeId.addObject(result.placeID)
                 }               
//                 self.placeId.addObject(result.placeID)
 //                print("placeId==\(self.placeId)")
        }

当我添加 self.placeId.addObject(result.placeID) 时,我崩溃了

我在 Nslog 中的结果值为

Result Restaurant{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x7b85acc0>";
}-A, Limpopo, South Africa{
} with placeID ChIJ91Ja9qr8wB4RJWDoiYanNIo
Result Restaurant{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x7b87d2e0>";
} Chayo, Mexico{
} with placeID ChIJP6GUHEmTvIYRc3CD5bAotiE
Result Restaurant{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x7b87d990>";
}e, Mexico{
} with placeID ChIJrV4AvelmyIYR7-jos-aGxDY

最佳答案

使用result.attributedFullText.string而不是result.attributedFullText

关于swift - 如何在 NsmutableArray 中快速获取 google 地点 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34309035/

相关文章:

objective-c - 在索引处编辑 NSMutable 数组

ios - CustomCell 为空或导致 SIGABRT 错误 [W/代码]

android - 如何在 Google Direction API 绘制的特定折线上将当前交通数据绘制到谷歌地图

google-maps - 如何通过他们的 API V3 获取显示在 Google map 上的路线的航点列表?

android - 在 xml 中设置 Google Map v2 上的 ImageView

objective-c - NSMutableArray arrayWithArray 与 NSArray mutableCopy 比较相同?

ios - 这些 MPMediaQuery 结果之间有什么区别?

ios - Swift:给定 UILabel 的宽度拆分字符串

cocoa - Swift 中的 SCNScene 问题 : nothing shows in SCNView

iphone - 使用对象子类的属性