I am currently facing issue while filter the array using predicate.
I have one modelclass named NoteModelClass
class NoteModelClass: NSObject {
var Post_ID = Int()
var NoteTitle = String()
var NoteDescription = String()
var FirstName = String()
var LastName = String()
var Address = String()
}
I also called one init method to parse jsonObject into modelClass
init(dict:NSDictionary)
{
self.Post_ID = dict.value(forKey: "Post_ID") as! Int
self.NoteTitle = dict.value(forKey: "NoteTitle") as! String
self.NoteDescription = dict.value(forKey:
"NoteDescription") as! String
self.FirstName = dict.value(forKey: "FirstName") as! String
self.LastName = dict.value(forKey: "LastName") as! String
self.Address = dict.value(forKey: "Address") as! String
}
I am parse json array like
for item in mainDict (array of json)
{
let model = NoteModelClass(dict: item as! NSDictionary)
self.arrProperty.add(model);
}
Now when user search I am filtering my array based on search string like that
let predicate = NSPredicate(format: "NoteTitle CONTAINS[c] %@", "test”)
arrFilterUsingSearch = self.arrProperty.filtered(using: predicate) as! NSMutableArray;
But I am getting crash on this line
arrFilterUsingSearch = self.arrProperty.filtered(using: predicate) as! NSMutableArray;
I have done same functionality in diffrentProject also but I dont know what I am doing wrong Also I am getting my model class in array like this :
Printing description of ((_TtC11NoteBuyerGo14NoteModelClass *)0x166738e0):
<NoteBuyerGo.NoteModelClass: 0x166738e0>
Can anyone give me solution or guide me that what I am doing wrong here ?
I am stuck with this , can anyone help me in this.
I am getting below crash:
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<NoteBuyerGo.NoteModelClass 0x14e5bdb0>
valueForUndefinedKey:]: this class is not key value coding-compliant
for the key NoteTitle.'
Help will be really appreciated.