包含多個數據類型我有這樣一個數組: -濾波陣列中Swift3
var arrayData : Array<Dictionary<String, [BottleModel]>> = []
瓶型: -
class BottleModel: NSObject {
var name : String
var price : Int
var reviews : Int
var category : String
var quantity : String
var id : String
var shopData : ShopModel
}
我想過濾的數組,其中價格> 2000
我嘗試let searchByInts = arrayData.filter({m in m.price < 200})
但收到錯誤:
Contextual closure type '(Dictionary) -> Bool' expects 1 argument, but 0 were used in closure body
如何篩選基於價格
價格是字符串,您可以將其與SRING –
比不上試試這個rrayData.filter({在INT(m.price M)<200}) –
@MikeAlter,好抓住。我更新我的模型 – pkc456