iphoneiosabpersonviewcontroller

Handling click events inside ABPersonViewController


I am implementing

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier

delegate in my custom class which subclasses ABPersonViewController. The delegate method is catching the click events inside the ABPersonViewController subclass. But how will I know which field exactly has been clicked. For eg. if I click on the home address field, how will I handle this case inside the delegate method.


Solution

  • - (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
    if(property == kABPersonAddressProperty){
        ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
        CFStringRef address = ABMultiValueCopyValueAtIndex(multi, identifier);
        NSLog(@"Address %@", (NSString *)address);
        // Do your tasks here
        CFRelease(address);
    }
    return YES;
    }
    

    Just like kABPersonAddressProperty you can check all other properties like phone number, email, url etc.