ios - Complements / intersection of two generic array filled with NSIndexPath -
ipstoreload.filter { !contains(self.ipstoinsert, {$0.row == $1.row}) }
i want expression work. need complements of 2 generic array: ipstoreload
\ ipstoinsert
. idea doing wrong?
this definition:
var ipstoinsert = [nsindexpath]() var ipstodelete = [nsindexpath]()
the trouble have 2 nested closure expressions (the 1 filter
, , 1 contains
). within closure expression, $0
, $1
refer arguments local closure expression – in case, writing expression contains
takes 2 arguments ($0
, $1
), , closure argument filter
looks if takes no arguments (hence swift complaining can't pass ()->_
argument filter
).
try naming arguments, so:
ipstoreload.filter { reload in !contains(ipstoinsert) { insert in reload.row == insert.row } }
Comments
Post a Comment