我正在对 AddressBook 进行一些测试,虽然我可以获得我正在寻找的数据,但我很好奇它是如何传递的。特别是 CFDictionaryRef。当我将它转换为 NSDictionary 并登录到控制台时,我只得到一个字符串值,而不是 key=value 对。如果我尝试记录 allKeys 我的测试应用程序会中断。
这是我正在使用的代码片段:
if ([contactName isEqualToString:ownerName]) { 
                    //get reference to  their email addresses
                    ABMultiValueRef contactEmails = ABRecordCopyValue(thisPerson, kABPersonEmailProperty);
                    //loop
                    for (NSUInteger e = 0; e < ABMultiValueGetCount(contactEmails); e++){
                        CFDictionaryRef thisPersonCFEmailDict = ABMultiValueCopyValueAtIndex(contactEmails, e);
                        NSDictionary* thisPersonEmailDict = (__bridge NSDictionary*)thisPersonCFEmailDict;
                        NSLog(@"%@", [thisPersonEmailDict allKeys]);
                    }
                }