使用[PKPayment billingAddress]
时会出现此问题,ABRecordRef
列为类型ABPersonRef
(但更确切地说,类型为{{1}})。
答案 0 :(得分: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);
}
也可以使用相同的方法获取kABPersonAddressCountryCodeKey
和kABPersonAddressCountryKey
属性。
不要忘记链接AddressBook
框架和#import <AddressBook/AddressBook.h>