对于单个PlaceID,Google提供了以下完美无瑕的代码 -
let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"
然而,如果我尝试像
这样的数组let mexican: GMSPlace = ["ChIJM8S9ACvoIogRmzYiLgzlP_g",
"ChIJwSHwoNTpIogRyElYj-kHC14",
"ChIJDWRMYifoIogR7S6U4tryodY",
"ChIJqSVd6yfoIogRmTgBSoO4Z0k",
"ChIJLacWlinoIogRVGYk-bZbGUE",
"ChIJSUC9S2zCIogRTKyiW0q_6tI"]
上下文类型不能与文字数组一起使用。如何创建一个包含GMSPlaceID的数组?
答案 0 :(得分:1)
您需要声明一个String
数组:
let mexican: [String] = ["ChIJM8S9ACvoIogRmzYiLgzlP_g",
"ChIJwSHwoNTpIogRyElYj-kHC14",
"ChIJDWRMYifoIogR7S6U4tryodY",
"ChIJqSVd6yfoIogRmTgBSoO4Z0k",
"ChIJLacWlinoIogRVGYk-bZbGUE",
"ChIJSUC9S2zCIogRTKyiW0q_6tI"]
所以而不是:
let mexican: GSMPlace
使用:
let mexican: [String]