Help us understand the problem. What is going on with this article?

iOS8でABPeoplePickerNavigationControllerの変更点

More than 5 years have passed since last update.

変更点

iOS7まで呼ばれていた以下のデリゲートメッソドが呼ばれなくなった。

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier

iOS8では以下のデリゲートメッソドとプロパティが新しく追加された。

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person


@property(nonatomic,copy) NSPredicate *predicateForEnablingPerson
@property(nonatomic,copy) NSPredicate *predicateForSelectionOfPerson
@property(nonatomic,copy) NSPredicate *predicateForSelectionOfProperty

既存コードの対応方法

1、新しく追加されたpeoplePickerNavigationController:didSelectPersonメッソド内で既存のpeoplePickerNavigationController:shouldContinueAfterSelectingPersonを呼ぶ。

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person
{
    [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person];
}

2、peoplePickerNavigationController:shouldContinueAfterSelectingPersonの戻り値で行った制御は新しいプロパティで行う

peoplePicker.predicateForSelectionOfPerson = [NSPredicate predicateWithFormat:@"%K.@count <= 1", ABPersonPhoneNumbersProperty];

//peoplePicker.predicateForSelectionOfPerson = [NSPredicate predicateWithFormat:@"%K.@count <= 1", ABPersonEmailAddressesProperty];

問題点

Blockを利用してpredicateを設定するとアプリが終了しちゃう、、、

peoplePicker.predicateForSelectionOfPerson = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
    return YES;
}];

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSBlockPredicate cannot be encoded or decoded'
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away