I am working on an app that requires me to make a call from yelp. In the yelp call, I want to replace the [.oneDollarSign, .twoDollarSigns] with "pricestring"
.
I get the following error when I change the code to priceTiers: pricestring
Cannot convert value of type '[String]' to expected argument type '[CDYelpPriceTier]?'
//Array declaration
var pricestring = [String]()
//Set pricestring
pricestring.append(".oneDollarSign, .twoDollarSigns")
//Yelp Call
yelpAPIClient.searchBusinesses(byTerm: "Food",
....
priceTiers: [.oneDollarSign, .twoDollarSigns], <----
attributes: nil)
From the CDYelpFusionKit Documentation:
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 $$$).
What do I have to do to be able to replace the [.oneDollarSign, .twoDollarSigns] with a variable?
Declare
//Array declaration
var priceLevels = [CDYelpPriceTier]()
Set
//Set pricestring
priceLevels.append(contentsOf: [.oneDollarSign, .twoDollarSigns])
and use it
, ... priceTiers: priceLevels, ...