Suppose I have one entity 'Person' in core data. Now i want to search all persons. Either firstname beginning match or lastname beginning match. For eg : 1) Amit Gupta 2) Ajay Gulati 3) Gunjan Aggarwal
Searching for 'Gu' shows names that match firstname first, then those that match lastname therefore result is :
Gunjan Aggarwal Ajay Gulati Amit Gupta
One option : Fetch all objects , store them in array and then sort. But what if the search results are very big in number
Second option : Use NSFetchedResultsController This will fetch all matching but not in the required manner(firstname before lastname). Cant use sort descriptors as it is not sorting on any key, but upon matching.
Can anybody help ?
EDIT : First name and lastname are two different attributes of 'Person' entity. Either Firstname matches or Lastname matches.
I want results with 'Firstname' match before than results with 'Lastname' match.
If you use sort descriptor, which 'Key' or 'attribute' will you mention ???