svjim
svjim

Reputation: 211

How do I retrieve an address from the iPhone's address book.

I have been able to retrieve properties such as the first name, last name etc. from the address book api, but I haven't been able to decipher the documentation on retrieving the actual address. If someone could help, that would be appreciated.

Along with that issues, the properties for the address have only one "street" yet it does support multiple lines for street (i.e. streetaddress1, streetaddress2). How is that handled?

Upvotes: 1

Views: 134

Answers (1)

Daniel Amitay
Daniel Amitay

Reputation: 6667

Take a look here and look at the "Address Property" section.

You will notice:

const ABPropertyID kABPersonAddressProperty;
const CFStringRef kABPersonAddressStreetKey;
const CFStringRef kABPersonAddressCityKey;
const CFStringRef kABPersonAddressStateKey;
const CFStringRef kABPersonAddressZIPKey;
const CFStringRef kABPersonAddressCountryKey;
const CFStringRef kABPersonAddressCountryCodeKey;

I assume you have used the following code to retrieve a records first name:

NSString *firstName = (NSString*)ABRecordCopyValue(record, kABPersonFirstNameProperty);

To get their City, do this:

NSString *cityName = (NSString*)ABRecordCopyValue(record, kABPersonAddressCityKey);

The rest can be found similarly!

Upvotes: 2

Related Questions