Monday, July 16, 2012

Fetch address for a contact from addressbook.


ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonAddressProperty);
    
    if(multi)
    {
        NSArray *address = (NSArray *)ABMultiValueCopyArrayOfAllValues(multi);
        for (int i = 0; i < [address count]; i++) {
        {
            NSDictionary *addressDict=[address objectAtIndex:i];
            NSString *country = [addressDict objectForKey:(NSString *)kABPersonAddressCountryKey];
            NSString *zip = [addressDict objectForKey:(NSString *)kABPersonAddressZIPKey];
            NSString *city = [addressDict objectForKey:(NSString *)kABPersonAddressCityKey];
            NSString *street = [addressDict objectForKey:(NSString *)kABPersonAddressStreetKey];
            
        }
    }

Similarly, you can fetch phone numbers as well as email address and other details by changing property kABPersonAddressProperty to corresponding property.

No comments:

Post a Comment