title: ABPeoplePickerNavigationController Facebook vs local data
body: <p>I have an ABPeoplePickerNavigationController that was working perfectly, but now it is not grabbing the values from my contacts and there have been no code changes.</p>
  
  <p>The contact has multiple phone numbers and in the past the people picker was seeing all of them, but now it is just seeing the information that is tagged as 'facebook'. So it is no longer seeing the local information, just the information in the facebook relationship.</p>
  
  <p>Preferably, is there a way to make sure I'm only looking at local data?</p>
  
  <p>-OR-</p>
  
  <p>Is there a way to determine which type of contact I'm looking at? I can deal with the 'facebook' data vs. 'local' but I would need to know which type of record I am working with to determine what data is available.</p>
  
  <p>Here is the method I am using (this works great if it's a local record):</p>
  
  <pre><code>- (void)pickPerson
  {
      ABPeoplePickerNavigationController *peoplePickerController = [[ABPeoplePickerNavigationController alloc] init];
      peoplePickerController.peoplePickerDelegate = self;
      [self presentModalViewController:peoplePickerController animated:YES];  
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
  {
      NSMutableDictionary *contactInfo = [[NSMutableDictionary alloc] initWithCapacity:13];
  
      ////// Get Person's Full Name
      //
      NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);
      if (name) {
          [contactInfo setObject:name forKey:@"name"];
      } else {
          [contactInfo setObject:@"" forKey:@"name"];
      }
  
      ////// Get Organization Name for Person
      //
      NSString *companyName = (__bridge NSString *)ABRecordCopyValue(person,kABPersonOrganizationProperty);
      if (companyName) {
          [contactInfo setObject:companyName forKey:@"companyName"];
      } else {
          [contactInfo setObject:@"" forKey:@"companyName"];
      }
  
      ////// Get phone
      //
      ABMultiValueRef phones = ABRecordCopyValue(person, kABPersonPhoneProperty);
      NSString *phoneLabel, *phoneStr;
      for (CFIndex i = 0; i &lt; ABMultiValueGetCount(phones); i++) {
          phoneLabel = (__bridge NSString *)ABMultiValueCopyLabelAtIndex(phones, i);
          if ([phoneLabel isEqualToString:desiredPhoneLabel]) {
              phoneStr = (__bridge NSString *)ABMultiValueCopyValueAtIndex(phones, i);
          }
      }
      if (phoneStr) {
          [contactInfo setObject:phoneStr forKey:@"phoneNumber"];
      } else {
          [contactInfo setObject:@"" forKey:@"phoneNumber"];
      }
  
      ////// Get twitter and facebook account for person
      //
      ABMutableMultiValueRef socialMulti = ABRecordCopyValue(person, kABPersonSocialProfileProperty);
      NSString *twitter, *facebook;
      for (CFIndex i = 0; i &lt; ABMultiValueGetCount(socialMulti); i++) {
          NSDictionary *social = (__bridge NSDictionary *)ABMultiValueCopyValueAtIndex(socialMulti, i);
          if ([social[@"service"] isEqualToString:(__bridge NSString *)kABPersonSocialProfileServiceTwitter]) {
              twitter = (NSString *)social[@"username"];
          }
          if ([social[@"service"] isEqualToString:(__bridge NSString *)kABPersonSocialProfileServiceFacebook]) {
              facebook = (NSString *)social[@"username"];
          }
      }
      if (twitter) {
          [contactInfo setObject:twitter forKey:@"twitter"];
      } else {
          [contactInfo setObject:@"" forKey:@"twitter"];
      }
      if (facebook) {
          [contactInfo setObject:facebook forKey:@"facebook"];
      } else {
          [contactInfo setObject:@"" forKey:@"facebook"];
      }
  
      ////// Get address
      //
      ABMultiValueRef addresses = ABRecordCopyValue(person, kABPersonAddressProperty);
      NSString *addressLabel, *streetAddress, *cityName, *stateName, *zipCode, *countryName;
      if (ABMultiValueGetCount(addresses) &gt; 0) {
          for (CFIndex i=0; i &lt; ABMultiValueGetCount(addresses); i++) {
              addressLabel = (__bridge NSString *)ABMultiValueCopyLabelAtIndex(addresses, i);
              if ([addressLabel isEqualToString:desiredAddressLabel]) {
                  NSDictionary *addressDict = (__bridge NSDictionary *)ABMultiValueCopyValueAtIndex(addresses, i);
                  streetAddress = [addressDict objectForKey:@"Street"];
                  cityName = [addressDict objectForKey:@"City"];
                  stateName = [addressDict objectForKey:@"State"];
                  zipCode = [addressDict objectForKey:@"ZIP"];
                  countryName = [addressDict objectForKey:@"Country"];
              }
          }
      }
      NSArray *streetAddressComponents = [streetAddress componentsSeparatedByString:@"\n"];
      if (streetAddressComponents[0]) {
          [contactInfo setObject:streetAddressComponents[0] forKey:@"addressStreet1"];
      } else {
          [contactInfo setObject:@"" forKey:@"addressStreet1"];
      }
      if (streetAddressComponents[1]) {
          [contactInfo setObject:streetAddressComponents[1] forKey:@"addressStreet2"];
      } else {
          [contactInfo setObject:@"" forKey:@"addressStreet2"];
      }
      if (cityName) {
          [contactInfo setObject:cityName forKey:@"city"];
      } else {
          [contactInfo setObject:@"" forKey:@"city"];
      }
      if (stateName) {
          [contactInfo setObject:stateName forKey:@"state"];
      } else {
          [contactInfo setObject:@"" forKey:@"state"];
      }
      if (zipCode) {
          [contactInfo setObject:zipCode forKey:@"postalCode"];
      } else {
          [contactInfo setObject:@"" forKey:@"postalCode"];
      }
      if (countryName) {
          [contactInfo setObject:countryName forKey:@"country"];
      } else {
          [contactInfo setObject:@"" forKey:@"country"];
      }
  
      ////// Get URL designated
      //
      ABMultiValueRef homepage = ABRecordCopyValue(person, kABPersonURLProperty);
      NSString *homepageLabel, *webPage;
      for (CFIndex i=0; i &lt; ABMultiValueGetCount(homepage); i++) {
          homepageLabel = (__bridge NSString *)ABMultiValueCopyLabelAtIndex(homepage, i);
          if ([homepageLabel isEqualToString:desiredHomepageLabel]) {
              webPage = (__bridge NSString *)ABMultiValueCopyValueAtIndex(homepage, i);
          }
      }
      if (webPage) {
          [contactInfo setObject:webPage forKey:@"webPage"];
      } else {
          [contactInfo setObject:@"" forKey:@"webPage"];
      }
  
      if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
          [self dismissViewControllerAnimated:NO completion:nil];
      } else {
          [self dismissModalViewControllerAnimated:NO];
      }
  
      [self.delegate didUpdateContactInfo:self withInfo:contactInfo];
      CFRelease(addresses);
  
      return NO;
  }
  </code></pre>
  
  <p>**Update: I am pretty sure this is related to adding iCloud to the contact which makes the local contact a composite of the linked contacts 'facebook' and 'iCloud'. So now I just need to check for linked contacts and pick the iCloud contact. back to my research...</p>