2014-08-28 1 views
2

에 대한 CFDictionaryRef 접근에 문제가 같은 ObjC에서 연락처의 주소 정보,스위프트 : I'v ABAddressBookRef

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

그래서, 해당 스위프트 코드는 것,

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 ... 
    } 

를 수집하는 방법은 거리를 가져옵니다 및 다른 유사한 정보?

답변

2

대신 NSDictionary을 사용할 수 있습니까? (테스트되지 않음)

if let dict : NSDictionary = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? NSDictionary 
{ 
let street = dict[kABPersonAddressStreetKey] 
} 
+0

아, 그래, 내가 dict .__ conversion()을 사용하여 해결 했으므로 CFDictionaryRef를 NSDictionary로 변환하지만 지금은 NSDictionary로 바로갑니다. 감사 – BaSha