Friday, 15 February 2013

objective c - Sorting contacts based on recently used/most used/urgency in AddressBook iOS -



objective c - Sorting contacts based on recently used/most used/urgency in AddressBook iOS -

i need sort contacts in user's device based on used/most used/urgency , display them in single view(not in phone app these displayed in separate tabs). have researched got know sorting contacts alphabetically. addressbook framework allow or there other way around? help appreciated.

no. unfortunately, there no way of knowing if record has been used or not.

however, can sort records in address book using properties specified below:

here simple illustration of sorting records based on creation date in descending order.

abaddressbookref addressbookref = abaddressbookcreatewithoptions(nil, null); abaddressbookrequestaccesswithcompletion(addressbookref, ^(bool granted, cferrorref error) { nsarray *allpeople = cfbridgingrelease(abaddressbookcopyarrayofallpeople(addressbookref)); nsarray *sortedpeople = [allpeople sortedarrayusingcomparator:^nscomparisonresult(id arecord, id otherrecord) { abrecordref arecordref = (__bridge abrecordref)arecord; abrecordref otherrecordref = (__bridge abrecordref)otherrecord; nsdate *arecordcreationdate = cfbridgingrelease(abrecordcopyvalue(arecordref, kabpersoncreationdateproperty)); nsdate *otherrecordcreationdate = cfbridgingrelease(abrecordcopyvalue(otherrecordref, kabpersoncreationdateproperty)); homecoming [arecordcreationdate compare:otherrecordcreationdate]; }]; }); cfrelease(addressbookref);

ios objective-c xcode sorting abaddressbook

No comments:

Post a Comment