When I filter an array of custom Swift classes using Predicate, I get an error:
*** NSForwarding: warning: object 0x78ed21a0 of class 'Plantivo1_6.Seed' does not implement the SignatureForSelector method: - the problem is ahead
Unrecognized selector - [Plantivo1_6.Seed valueForKey:]
If I remember correctly, this will work in Objective-C. What is my mistake?
let names = ["Tom","Mike","Marc"] println(names) let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", "om") let array = (names as NSArray).filteredArrayUsingPredicate(searchPredicate) println(array) println() let mySeed1 = Seed() // Seed is a class with a `culture` String property let mySeed2 = Seed() let mySeed3 = Seed() mySeed1.culture = "Tom" mySeed2.culture = "Mike" mySeed3.culture = "Marc" let mySeeds = [mySeed1,mySeed2,mySeed3] println(mySeeds) let searchPredicate1 = NSPredicate(format: "SELF.culture CONTAINS[c] %@", "om") let array1 = (mySeeds as NSArray).filteredArrayUsingPredicate(searchPredicate1) println(array1)
source share