This question arose while using [PKPayment billingAddress]
, which is listed as type ABRecordRef
(but to be more precise, is of type ABPersonRef
).
Asked
Active
Viewed 209 times
-1

rmaddy
- 314,917
- 42
- 532
- 579

codeperson
- 8,050
- 5
- 32
- 51
-
The "Address Book Programming Guide for iOS" tells you how to do this. – rmaddy Oct 27 '14 at 23:24
-
IMO it's opaque and hard to find, and AddressBook's C APIs are inconvenient to use and hard to understand. – codeperson Oct 27 '14 at 23:31
-
@rmaddy, Is that telling how to get Email and Phone number from Passbook ( Apple Pay). I tried but its nil always :( – Femina Mar 16 '15 at 14:22
1 Answers
0
NSString *streetAddress;
if (ABMultiValueGetCount(addressMultiValueRef) > 0) {
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressMultiValueRef, 0);
streetAddress = (__bridge NSString *)CFDictionaryGetValue(dict, kABPersonAddressStreetKey);
}
NSString *city;
if (ABMultiValueGetCount(addressMultiValueRef) > 0) {
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressMultiValueRef, 0);
city = (__bridge NSString *)CFDictionaryGetValue(dict, kABPersonAddressCityKey);
}
NSString *state;
if (ABMultiValueGetCount(addressMultiValueRef) > 0) {
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressMultiValueRef, 0);
state = (__bridge NSString *)CFDictionaryGetValue(dict, kABPersonAddressStateKey);
}
NSString *zip;
if (ABMultiValueGetCount(addressMultiValueRef) > 0) {
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressMultiValueRef, 0);
zip = (__bridge NSString *)CFDictionaryGetValue(dict, kABPersonAddressCityKey);
}
The same method can be used to get the kABPersonAddressCountryCodeKey
and kABPersonAddressCountryKey
properties as well.
Don't forget to link against the AddressBook
framework and #import <AddressBook/AddressBook.h>

codeperson
- 8,050
- 5
- 32
- 51
-
How can I get values like Email , Phone number etc from Passbook (Apple Pay) ? – Femina Mar 16 '15 at 14:21