class Test: NSObject {
var product_id: String
var size: String
var color: String
var desc: String
var name: String
init(arr: [String]) {
product_id = arr[0]
size = arr[1]
color = arr[2]
desc = arr[3]
name = arr[4]
}
}
let t1 = Test(arr: ["1", "S", "Blue", "111", "第一个商品"])
let t2 = Test(arr: ["1", "S", "Blue", "333", "第三个商品"])
let t3 = Test(arr: ["1", "S", "Blue", "666", "第六个商品"])
let t4 = Test(arr: ["1", "S", "Blue", "777", "第七个商品"])
let t5 = Test(arr: ["2", "S", "Blue", "222", "第二个商品"])
let t6 = Test(arr: ["2", "S", "Blue", "555", "第五个商品"])
let t7 = Test(arr: ["3", "S", "Blue", "444", "第四个商品"])
let initialSWSet = Set([t1, t2, t3, t4, t5, t6, t7])
initialSWSet.count
我期望initialSWSet.count == 3,换句话说,如果测试的product_id,size,color是相同的,那么测试是相同的.t1 == t2 == t3 == t4; t5 == t6; T7 我怎样才能完成这项工作? 谢谢提前!