Hi, I am using address book in my application. I get contacts in simulator. But in iPhone 4S it does not show any contacts in device. And in iPhone 4 I get only 1 contact. I don't understand why it not show all contacts. I am using following code. Please help me.
ABAddressBookRef ab=ABAddressBookCreate();
NSArray *arrTemp=(NSArray *)ABAddressBookCopyArrayOfAllPeople(ab);
UIImage* image;
ContactArray=[[NSMutableArray alloc] init];
for (int i=0;i<[arrTemp count];i++)
{
NSMutableDictionary *dicContact=[[NSMutableDictionary alloc] init];
NSString *str=(NSString *) ABRecordCopyValue([arrTemp objectAtIndex:i], kABPersonFirstNameProperty);
UIImage *imgContactImage=(UIImage *)ABPersonCopyImageDataWithFormat([arrTemp objectAtIndex:i],kABPersonImageFormatOriginalSize);
if(ABPersonHasImageData([arrTemp objectAtIndex:i])){
image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData([arrTemp objectAtIndex:i])];
} else {
image = [UIImage imageNamed:@""];
}
NSString* phoneNumber=@"";
NSString *mobileLabel=@"";
//Get mobile phone number
ABMultiValueRef phoneNumbers = (ABMultiValueRef)ABRecordCopyValue([arrTemp objectAtIndex:i], kABPersonPhoneProperty);
CFRelease(phoneNumbers);
if(ABMultiValueGetCount(phoneNumbers)>0) {
for(CFIndex j = 0; j < ABMultiValueGetCount(phoneNumbers); j++) {
mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phoneNumbers, j);
if([mobileLabel isEqualToString:@"_$!<Mobile>!$_"]) {
phoneNumber = (NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, j);
}
}
}
else
{
phoneNumber=@"";
}
NSLog(@"%@",phoneNumber);
}