I have people picker working on ios 7, and I'm trying to add compatibility for ios 8. I've added both methods into one but I get an error that says expected identifier or '(' on the opening bracket before NSString *contactName. Any suggestions would be great!
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
NSString *contactName = CFBridgingRelease(ABRecordCopyCompositeName(person));
self.nameField.text = [NSString stringWithFormat:@"%@", contactName ? contactName : @"No Name"];
ABMultiValueRef phoneRecord = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phoneRecord, 0);
self.phoneField.text = (__bridge_transfer NSString *)phoneNumber;
CFRelease(phoneRecord);
ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailField = ABMultiValueCopyValueAtIndex(email, 0);
self.emailField.text = (__bridge_transfer NSString *)emailField;
CFRelease(email);
CFDataRef photo = ABPersonCopyImageData(person);
UIImage* image = [UIImage imageWithData:(__bridge NSData*)photo];
if(photo)
CFRelease(photo);
if(image)
self.myImageView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
[self dismissViewControllerAnimated:YES completion:nil];
return NO; }
For anyone who might be interested this is my working code, for both ios 7 and ios 8
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
NSString *contactName = CFBridgingRelease(ABRecordCopyCompositeName(person));
self.nameField.text = [NSString stringWithFormat:@"%@", contactName ? contactName : @"No Name"];
ABMultiValueRef phoneRecord = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phoneRecord, 0);
self.phoneField.text = (__bridge_transfer NSString *)phoneNumber;
CFRelease(phoneRecord);
ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailField = ABMultiValueCopyValueAtIndex(email, 0);
self.emailField.text = (__bridge_transfer NSString *)emailField;
CFRelease(email);
CFDataRef photo = ABPersonCopyImageData(person);
UIImage* image = [UIImage imageWithData:(__bridge NSData*)photo];
if(photo)
CFRelease(photo);
if(image)
self.myImageView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
[self dismissViewControllerAnimated:YES completion:nil];
return NO; }