title: Choosing an Email from the address book - iOS
body: <p>I'm trying to select the email id the user wants from the address book. When the user selects the work email or home email, then the corresponding value should be added to the variable. Any suggestion on this? Attached below is my code:</p>
  
  <pre><code>-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
  if(property == kABPersonEmailProperty){
      CFStringRef value, label;
      ABMutableMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
      CFIndex count = ABMultiValueGetCount(multi);
      if (count == 1)
      {
          value = ABMultiValueCopyValueAtIndex(multi, 0);
          email = (__bridge NSString*) value;
          NSLog(@"self.emailID   %@",email);
          CFRelease(value);
      }
      else
      {
  
          for (CFIndex i = 0; i &lt; count; i++)
          {
              label = ABMultiValueCopyLabelAtIndex(multi, i);
              value = ABMultiValueCopyValueAtIndex(multi, i);
                              // check for Work e-mail label
              if (CFStringCompare(label, kABWorkLabel, 0) == 0)
              {
                  email = (__bridge NSString*) value;
                  NSLog(@"self.emailID   %@",email);
                  NSLog(@"%@",(__bridge NSString *)label);
  
              }
  
              if(CFStringCompare(label, kABHomeLabel, 0) == 0)
              {
                  email = (__bridge NSString*) value;
                  NSLog(@"self.emailID   %@",email);
              }
  
              CFRelease(label);
              CFRelease(value);
          }
      }
      CFRelease(multi);
      [self displayPerson:person];
  
  }else{
      UIAlertView *testAlert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Please choose a valid email" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];
      testAlert.tag = 100;
      [testAlert show];
  }
  
  
    return NO;
  }
  </code></pre>