如何在NsmutableArray swift中获取google place id?

时间:2015-12-16 10:06:18

标签: 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

1 个答案:

答案 0 :(得分:0)

使用result.attributedFullText.string代替result.attributedFullText