iphoneiosipadios7abpersonviewcontroller

Issue when checking if current viewController class is ABPersonViewController in IOS 7


I am loading ABPeoplePickerNavigationController. On the click of a contact in the peoplepicker, I am checking a condition

if([navigationController isKindOfClass:[ABPeoplePickerNavigationController class]]
   && [viewController isKindOfClass:[ABPersonViewController class]]){

  //Statements

}

But in IOS 7 I have noticed that, the second condition, that is

[viewController isKindOfClass:[ABPersonViewController class]

returns NO all the time. I know that the viewcontroller that is loaded is ABPersonViewController. This was/is working fine until IOS 6. What could be the problem? Is there anyway I can get around this issue.

Edit:

The condition is checked inside UINavigationController Delegate

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

And the viewController class is shown as ABContactViewController when logged.


Solution

  • When checking your class you will find that iOS7 returns a different type.

    Review the logic for which you need the check. You should not have to use introspection to react appropriately to a people picker action. Just implement the standard delegate method from ABPeoplePickerNavigationControllerDelegate. In particular, you have to implement:

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