I have a project I'm trying to convert to Swift 3.0, which includes the following code:
if let array = games?.array as? [SMCGame] {
let wonPredicate = NSPredicate(format: "actualTime <= %@ && (homeScore > opponentScore)", [date])
let wonArray = (array as NSArray).filtered(using: wonPredicate)
}
This works fine in Swift 2.2 and 2.3, but in 3.0 I get the following runtime error on the last line: -[_TtCs21_SwiftDeferredNSArray timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x7f96614520d0
How can I get this working in Swift 3.0?
I think the problem is with your predicate construction.
let wonPredicate = NSPredicate(format: "actualTime <= %@ && (homeScore > opponentScore)", [date])Shouldn’t that be:
let wonPredicate = NSPredicate(format: "actualTime <= %@ && (homeScore > opponentScore)", date as NSDate)?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"