i was using xcode 3.2 yesterday on 10.6, I upgraded to 10.7 with xcode 4.2 the address book project which worked well in xcode 3.2, doesn’t work in the new version of xcode, the following error is: (/Users/Blake/Development/g/g/ViewController.m:37:37:{37:37-37:56}{37:48-37:56}: error: cast of C pointer type ‘CFStringRef’ (aka ‘const struct __CFString *’) to Objective-C pointer type ‘NSString *’ requires a bridged cast [4]
phones = [[NSMutableArray alloc] init];
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef peopleRecords = ABAddressBookCopyArrayOfAllPeople(addressBook);
for (int i = 0; i < CFArrayGetCount(peopleRecords); ++i)
{
ABRecordRef recordRef = CFArrayGetValueAtIndex(peopleRecords, i);
ABMultiValueRef phoneRefs = ABRecordCopyValue(recordRef, kABPersonPhoneProperty);
for (int a = 0; a < ABMultiValueGetCount(phoneRefs); ++a)
{
CFStringRef phoneStr = ABMultiValueCopyValueAtIndex(phoneRefs, a);
NSString* phoneString = (NSString*)phoneStr;
[phones addObjectphoneString];
CFRelease(phoneStr);
}
CFRelease(phoneRefs);
}
CFRelease(addressBook);
CFRelease(peopleRecords);
for (NSString *phone in phones)
{
NSLog(@"%@", phone) ;
}
I do it like this:
Then I iterate the phoneNumbersArray for NSString.