ios - Core Data NSPredicate not working -
this question has answer here:
please me there no specific error, run time stop
func fachdatabyid(entityname: string, colummname: string, value: int) -> bool { let appdeleget = uiapplication.sharedapplication().delegate as! appdelegate let manegecontext = appdeleget.managedobjectcontext let fetchrequist = nsfetchrequest(entityname: entityname) print("ok fetchrequist") fetchrequist.predicate = nspredicate(format: "%k == %@", colummname, value) do{ let results = try manegecontext.executefetchrequest(fetchrequist) print(results) return true } catch{ print("error") return false } }
the problem %@ format value:int , cast value nsobject or anyobject following:
nspredicate(format: "%k == %@", colummname, value nsobject)
Comments
Post a Comment