ios - NSPredicate: Getting the highest value -
i've got following:
let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate let managedobjcontext = appdelegate.managedobjectcontext let fetchrequest = nsfetchrequest(entityname: "ras") var error: nserror? let predicate1 = nspredicate(format: "%k , %k == false", "rasscore", "rasstatus") fetchrequest.predicate = predicate1 {...
this gives me records conform parameters of nspredicate, want record highest value in rasscore
. how go getting that? possible include in nspredicate format?
set fetchlimit
of fetchrequest
1 , use descriptor sort value of "rasscore"
descending this:
fetchrequest.fetchlimit = 1 var highestsortdescriptor : nssortdescriptor = nssortdescriptor(key: "rasscore", ascending: false) fetchrequest.sortdescriptors = [highestsortdescriptor]
Comments
Post a Comment