Swift filter array of objects

前端 未结 7 947
忘了有多久
忘了有多久 2021-02-03 20:44
class book{
    var nameOfBook: String!
}

var englishBooks=[book(),book(),book()]
var arr = englishBooks.filter {
    contains($0.nameOfBook, \"rt\")
}
<
7条回答
  •  梦如初夏
    2021-02-03 21:12

    in case you want to delete an interval of object which has specific IDs (matchIDsToDelete) from an array of object (matches)

    var matches = [Match]
    var matchIDsToDelete = [String]
    matches = matches.filter { !matchIDsToDelete.contains($0.matchID) }
    

提交回复
热议问题