如何保存GMSPlace数组

时间:2017-09-03 06:48:41

标签: arrays swift xcode google-places-api

对于单个PlaceID,Google提供了以下完美无瑕的代码 -

let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"

然而,如果我尝试像

这样的数组
let mexican: GMSPlace = ["ChIJM8S9ACvoIogRmzYiLgzlP_g",
"ChIJwSHwoNTpIogRyElYj-kHC14",
"ChIJDWRMYifoIogR7S6U4tryodY",
"ChIJqSVd6yfoIogRmTgBSoO4Z0k",
"ChIJLacWlinoIogRVGYk-bZbGUE",
"ChIJSUC9S2zCIogRTKyiW0q_6tI"]

上下文类型不能与文字数组一起使用。如何创建一个包含GMSPlaceID的数组?

1 个答案:

答案 0 :(得分:1)

您需要声明一个String数组:

let mexican: [String] = ["ChIJM8S9ACvoIogRmzYiLgzlP_g",
"ChIJwSHwoNTpIogRyElYj-kHC14",
"ChIJDWRMYifoIogR7S6U4tryodY",
"ChIJqSVd6yfoIogRmTgBSoO4Z0k",
"ChIJLacWlinoIogRVGYk-bZbGUE",
"ChIJSUC9S2zCIogRTKyiW0q_6tI"]

所以而不是:

let mexican: GSMPlace

使用:

let mexican: [String]