Being fairly new to objective-c and developing for ios I’m trying to figure out how to implement the addressbook code from Address Book Programming Guide for iOS.
I want to be able to log the address a user clicked on in the addressbook.
I managed to implement the addressbook in my app.
In ios4 the following ‘works’:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
if (property == kABPersonAddressProperty) // if tapped is equal to a phone property
{
NSLog(@"Address tapped!");
NSMutableDictionary * cfaddress;
ABMultiValueRef address = ABRecordCopyValue(person, kABPersonAddressProperty);
for(CFIndex i = 0; i < ABMultiValueGetCount(address); i++) {
if(identifier == ABMultiValueGetIdentifierAtIndex (address, i)) { //if tapped number identifier is the same as identifier number tapped
cfaddress = ABMultiValueCopyValueAtIndex(address, i); // copy the number to CFSTRING number
}
}
NSLog(@"%@", [cfaddress objectForKey:@"City"]);
NSLog(@"%@", [cfaddress objectForKey:@"Street"]);
// City and street present ?
if([cfaddress objectForKey:@"City"] && [cfaddress objectForKey:@"Street"]){
NSLog(@"STAD EN STRAAT");
}
else{
NSLog(@"GEEN STAD EN/OF STRAAT");
}
}
[self dismissModalViewControllerAnimated:YES];
return YES;
}
Unfortunately in ios5 with Automatic reference counting on this gives me the following error:
error: Automatic Reference Counting Issue: Implicit conversion of a non-Objective-C pointer type ‘CFTypeRef’ (aka ‘const void *’) to ‘NSMutableDictionary *’ is disallowed with ARC
I’m guessing my way of doing this (for ios4) wasn’t a good way anyway and I would really appreciate some suggestions on how to achieve this. Thanks in advance!
repalace this
with this