I have done the following to get record for user info from address book.
- (ABRecordRef)findRecordNSString *)phoneNumber
{
if (phoneNumber == nil)
return nil;
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef all = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex n = ABAddressBookGetPersonCount(addressBook);
ABRecordRef record;
//NSLog(@"The Record : %d", record);
int count = 0;
for( int i = 0 ; i < n ; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex(all, i);
ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
{
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);
NSString *newPhoneNumber = (NSString *)phoneNumberRef;
if([newPhoneNumber isEqualToStringhoneNumber])
{
//NSLog(@"Phone Ref: %@", phoneNumberRef);
NSLog(@"Record New: %d", ref);
record = ref;
i=(int)n;
count = 1;
}
CFRelease(phoneNumberRef);
[newPhoneNumber release];
}
}
[addressBook release];
return record;
}
but i am getting an error when I try to open the viewController in ios5 device but it works in simulator and ios 4. the error is
Program received signal: “EXC_BAD_ACCESS”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Can't find dlopen function, so it is not possible to load shared libraries.)
Also after this error if I forcefully clos the app by double tapping home button and then quit manually the app will only show a black screen. Any idea regarding this?