I get the error *** Terminating app due to uncaught exception 'Invalid property name', reason: 'Property 'read' not found in object of type 'Book'' when I want to filter my data. My structure:
class Book: Object, Codable {
@objc dynamic var author = ""
@objc dynamic var title = ""
@objc dynamic var imageLink = ""
@objc dynamic var category = "Lk"
@objc dynamic var date = Date()
convenience init(withBookDict: [String: Any]) {
self.init()
self.author = withBookDict["author"] as? String ?? "No Author"
self.title = withBookDict["title"] as? String ?? "No Title"
self.imageLink = withBookDict["imageLink"] as? String ?? "No link"
self.category = withBookDict["category"] as? String ?? "No category"
}
}
my code for filtering data is this:
let filteredread = realm.objects(Book.self).filter({ $0.category == "read"})
but I also tried this:
let filteredread = realm.objects(Book.self).filter("category == 'read'")
also I did update my realm pod since there have been version issues.