2

I'v collected contact's address information in ObjC as,

ABMultiValueRef addressProperty = ABRecordCopyValue(contactRef, kABPersonAddressProperty);
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addressProperty, 0);
   if(dict)
   {
     NSString *street = (NSString *)CFDictionaryGetValue(dict, kABPersonAddressStreetKey);
   }

So, equivalent Swift code would be,

let addressProperty : ABMultiValueRef = ABRecordCopyValue(contactRef, kABPersonAddressProperty).takeUnretainedValue() as ABMultiValueRef

    if let dict : CFDictionaryRef = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? CFDictionaryRef
    {
     let street = CFDictionaryGetValue(dict,kABPersonAddressStreetKey)
    // Stuck here, among  CFString!, UnsafePointer<Void>, CFDictionaryRef ...
    }

How will I fetch street and other similar information?

BaSha
  • 2,356
  • 3
  • 21
  • 38

1 Answers1

2

Can you use NSDictionary instead? (not tested)

if let dict : NSDictionary = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? NSDictionary
{
 let street = dict[kABPersonAddressStreetKey]
}
newacct
  • 119,665
  • 29
  • 163
  • 224
  • Oh yes it is working, I had fixed it with dict.__conversion(), which is converting CFDictionaryRef to NSDictionary but now I'm going for NSDictionary directly. Thanks – BaSha Aug 29 '14 at 05:19