Swift filter array of objects

前端 未结 7 938
忘了有多久
忘了有多久 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:09

    SWIFT 4.0

    In order to filter objects and get resultant array you can use this

    self.resultArray = self.upcomingAuctions.filter {
                        $0.auctionStatus == "waiting"
                    }
    

提交回复
热议问题