人们select与ios 7和ios 8

我有人select工作在ios 7,我试图添加兼容性为ios 8.我已经将两个方法添加到一个,但我得到一个错误,说预期的标识符或'('在NSString * contactName任何build议将是伟大的!

- (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; } 

对于任何人可能感兴趣,这是我的工作代码,对于iOS 7和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; } 

当委托方法的签名更新为新的iOS版本时,旧的版本会保留一段时间。 答案是: 实现新的和旧的方法 ,正确的将被自动调用。