0

Currently we are able to fetch all the contacts in the addressbook using ABAddressBookCopyArrayOfAllPeople which returns an Array of contact objects. If we have a huge number of contacts on the phone then the memory being allocated to the array will be significant. To avoid heavy memory consumption, we would like to fetch one contact at a time from the addressbook by programmatically accessing the database directly.

Provision for this is available using either RecordID or PeopleName. Without the array of contact objects we could not obtain either as we want to avoid using the array in the first place.

Is there any method to fetch one contact from the addressbook database instead and move the cursor to the next contact and fetch the next contact ? Android has a provision for doing this and we were hoping there was a similar method in iOS ?

Alexander
  • 25
  • 5
  • I think it is not possible in iOS. But if we have 10,000 contacts then it should not be a problem because `ABAddressBookCopyArrayOfAllPeople` function is giving you an array of references to `ABPerson`. The function is not giving us the copy of the whole address book so memory overhead is not be a problem. – Adeel Ur Rehman Dec 18 '14 at 10:09
  • Yes, went through the Apple document and there seems to be no API to get one contact at a time. Are you sure that ABAddressBookCopyArrayOfAllPeople returns only an array of references to the the actual ABperson contact class ? This would ensure the memory consumption is not going to be as massive as I had thought before. – Alexander Dec 18 '14 at 11:15
  • if you can see the return type from `ABPerson` class reference you can see that the method is returning `CFArrayRef` which is a pointer to the actual objects (just like the cursor in java) – Adeel Ur Rehman Dec 18 '14 at 11:21
  • Yes, you were right about it. Memory was being utilized by too many strings being allocated statically. Have rectified this issue, thank you very much. – Alexander Dec 22 '14 at 08:32
  • You are always welcome. – Adeel Ur Rehman Dec 22 '14 at 08:35

0 Answers0