无法将类型“[String]”的值转换为预期的参数类型“[CDYelpPriceTier]?”
Cannot convert value of type '[String]' to expected argument type '[CDYelpPriceTier]?'
我正在开发一个需要我从 yelp 拨打电话的应用程序。在 yelp 调用中,我想替换 [.oneDollarSign, .twoDollarSigns] with "pricestring"
.
当我将代码更改为 priceTiers: pricestring
时出现以下错误
无法将“[String]”类型的值转换为预期的参数类型“[CDYelpPriceTier]?”
//Array declaration
var pricestring = [String]()
//Set pricestring
pricestring.append(".oneDollarSign, .twoDollarSigns")
//Yelp Call
yelpAPIClient.searchBusinesses(byTerm: "Food",
....
priceTiers: [.oneDollarSign, .twoDollarSigns], <----
attributes: nil)
来自 CDYelpFusionKit 文档:
price: (Optional) The pricing levels to filter the search result with.
Use the **CDYelpPriceTier** enum to get the list of supported pricing levels.
`price` can be an array of pricing levels (e.g. [.oneDollarSign, .twoDollarSigns, .threeDollarSigns] will filter the results to show businesses that are listed as $, $$, or $$$).
我需要做什么才能用变量替换 [.oneDollarSign, .twoDollarSigns]?
声明
//Array declaration
var priceLevels = [CDYelpPriceTier]()
设置
//Set pricestring
priceLevels.append(contentsOf: [.oneDollarSign, .twoDollarSigns])
并使用它
, ... priceTiers: priceLevels, ...
我正在开发一个需要我从 yelp 拨打电话的应用程序。在 yelp 调用中,我想替换 [.oneDollarSign, .twoDollarSigns] with "pricestring"
.
当我将代码更改为 priceTiers: pricestring
无法将“[String]”类型的值转换为预期的参数类型“[CDYelpPriceTier]?”
//Array declaration
var pricestring = [String]()
//Set pricestring
pricestring.append(".oneDollarSign, .twoDollarSigns")
//Yelp Call
yelpAPIClient.searchBusinesses(byTerm: "Food",
....
priceTiers: [.oneDollarSign, .twoDollarSigns], <----
attributes: nil)
来自 CDYelpFusionKit 文档:
price: (Optional) The pricing levels to filter the search result with.
Use the **CDYelpPriceTier** enum to get the list of supported pricing levels.
`price` can be an array of pricing levels (e.g. [.oneDollarSign, .twoDollarSigns, .threeDollarSigns] will filter the results to show businesses that are listed as $, $$, or $$$).
我需要做什么才能用变量替换 [.oneDollarSign, .twoDollarSigns]?
声明
//Array declaration
var priceLevels = [CDYelpPriceTier]()
设置
//Set pricestring
priceLevels.append(contentsOf: [.oneDollarSign, .twoDollarSigns])
并使用它
, ... priceTiers: priceLevels, ...