我有这个问题,而且我对Swift更新。我试过在互联网上四处寻找并找到看起来正确的东西,但出于某种原因我无法使用它。这是我正在使用的片段:
/** This struct is meant to hold all of the information taken from the firebase database */
struct Service {
var name: String
var description: String
var hours: String
var type: String
var estimated_payment: String
var ge_min_payment: String
var hourly_rate: String
var income_category: String
var part_cost: String
var part_markup: String
var standard_price: String
var task_number: String
var ttsp_price: String
var ttsp_savings: String
var agreement_discount: String
var annual_part_increase: String
}
// ...
/** cartArray contains all the objects currently in the cart for checkout */
var cartArray: [Service] = []
// ....
/**
* isInCart
*
* a boolean function which checks to see if a specific service object is in the array
*/
func isInCart(service: Service) -> Bool {
var contained = self.cartArray.contains(service)
return contained ? true : false;
}
当我尝试编译这个项目时,这是我收到的错误:
我对这有什么问题感到有些困惑。有人可以帮忙吗?