ABAddressBookGetPersonCount(ab) problem

Posted by prathumca on Stack Overflow See other posts from Stack Overflow or by prathumca
Published on 2010-04-06T07:58:31Z Indexed on 2010/04/06 8:03 UTC
Read the original article Hit count: 441

Filed under:
|
|

Why the call to ABAddressBookGetPersonCount(ab); is giving the problem? I have around 2000 contacts in my address book. When my app gets started I'm trying to read the entire address book. This works perfectly on simulator but causing crash on IPhone. The crash report is pointing to

9   AppSupport                      0x31fbca1e 0x31fb6000 + 27166   //
    CPRecordStoreGetCountOfInstancesOfClassWhere + 0x7e
10  AddressBook                     0x318df668 0x318d5000 + 42600   //
    ABCGetPersonCountInStore + 0x88
11  AddressBook                     0x318ea450 0x318d5000 + 87120   // 
    ABAddressBookGetPersonCount + 0x8
12  MyAddressBook                       0x0000ad30 0x1000 + 40240   // 
    -[MyAddressBookController readAB] + 0x2c0
13  MyAddressBook                       0x0000a8ce 0x1000 + 39118   // 
    -[MyAddressBookController start] + 0x4a

What I'm doing in "readAB"?

- (void) readAB
{
     ABAddressBookRef ab = ABAddressBookCreate();
     CFArrayRef contacts = ABAddressBookCopyArrayOfAllPeople(ab);
     CFIndex count = ABAddressBookGetPersonCount(ab);
     for(int i = 0; i < count; i++)
     {
          //doing some thing...
     }
}

If you observe the above crash report, it is clearly pointing to CFIndex count = ABAddressBookGetPersonCount(ab);. Whats wrong with this code? I'm sure that this code works perfectly on firmware 3.1.2. But now I upgraded firmware to 3.1.3. Is this upgrade is causing any trouble?

Regards, prathumca.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about objective-c