I have a method for getting all the contacts from the iPhone contacts app and i want to add the phone numbers to an object after i have removed all the spaces in the phone number string. The problem is that this only works for some of the contacts. I have noticed that in the debugger the string-objects sometimes show in a blue color and sometimes in black. Anybody have a clue what is going on here?
Images:
Does not remove spaces in phone number
Removes spaces in phone number
Code:
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
CFArrayRef sortedPeople = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName);
//RETRIEVING THE FIRST NAME AND PHONE NUMBER FROM THE ADDRESS BOOK
CFIndex number = CFArrayGetCount(sortedPeople);
NSString *firstName;
NSString *phoneNumberFromContact;
for(int i = 0; i < number; i++)
{
    ABRecordRef person = CFArrayGetValueAtIndex(sortedPeople, i);
    firstName = (__bridge NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    ABMultiValueRef phones = ABRecordCopyValue(person, kABPersonPhoneProperty);
    phoneNumberFromContact = (__bridge NSString *) ABMultiValueCopyValueAtIndex(phones, 0);
    if(phoneNumberFromContact != NULL)
    {
        Contact *contact = [[Contact alloc]init];
        contact.firstName = firstName;
        phoneNumberFromContact = [phoneNumberFromContact stringByReplacingOccurrencesOfString:@" " withString:@""];
        contact.phoneNumber = phoneNumberFromContact;
        [self.contacts addObject:contact];
    }
}
 
    