I have an array of objects that are all of class PFObject
.
I have a subclass of PFObject
called GameCategory
where some of the PFObject
s in my array are GameCategory
.
I was wondering how to write a first/where statement that would check each object to see if it is of class GameCategory, then check for a matching ID.
Here is my non-working attempt to do this:
for id in Ids {
if let object = self.matchObjects.first(where: {
if let gameCategory = $0 as? GameCategory {
gameCategory.id == id
}
}) {
//object successfully cast as GameCategory, and the GameCategory id was a match
}
}
This code returns the error 'Missing return in a closure expected to return 'Bool'.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…