2 Stimmen

E-Mail-Adressen aus dem iPhone-Adressbuch abrufen

Ich bin derzeit in der Lage, erfolgreich auf Daten aus der Datenbank zuzugreifen und diese abzurufen. peoplePickerNavigationController Ich möchte jedoch die E-Mail-Adresse des Kontakts aufrufen und das modale Fenster schließen, wenn der Kontaktname gedrückt wird.

Szenario:

"Button is clicked to add a contact
AddressBook Modal Window slides into view
Name of Contact is pressed
If available, the contact's email address is stored in an array
Dismiss modal window"

Mein derzeitiger Code besteht aus:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    ABMultiValueRef container = ABRecordCopyValue(person, property);
    CFStringRef contactData = ABMultiValueCopyValueAtIndex(container, identifier);
    CFRelease(container);
    NSString *contactString = [NSString stringWithString:(NSString *)contactData];
    CFRelease(contactData);

    NSLog(@"Value is: %@", contactString);

    [self dismissModalViewControllerAnimated:YES];  
    return NO;
}

5voto

John Stallings Punkte 571

Ich mache Folgendes.

if(property == kABPersonEmailProperty) {
  CFTypeRef prop = ABRecordCopyValue(person, property);
  CFIndex index = ABMultiValueGetIndexForIdentifier(prop,  identifierForValue);
  NSString *email = (NSString *)ABMultiValueCopyValueAtIndex(prop, index);

  ...

  CFRelease(prop);
  [email release];
}

CodeJaeger.com

CodeJaeger ist eine Gemeinschaft für Programmierer, die täglich Hilfe erhalten..
Wir haben viele Inhalte, und Sie können auch Ihre eigenen Fragen stellen oder die Fragen anderer Leute lösen.

Powered by:

X