空白字段显示在iPhone AddressBook上,如何调试? [英] Blank field showing up on iPhone AddressBook, how to debug?

查看:118
本文介绍了空白字段显示在iPhone AddressBook上,如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码通过名字和姓氏创建了我的通讯录中所有联系人的数组。问题是,我有一个联系人,显示一个空的名字和姓氏。我在实际的通讯录中找不到该联系人。任何人都可以建议如何调试这个来找出神秘鬼接触的源头。

The following code creates me an array of all my contacts in my address book by first name and last name. The problem is, I have one contact that keeps showing up with an empty first name and last name. I can't find that contact in my actual address book. Can anyone suggest how to debug this to figure out the source of the mystery ghost contact?

ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
NSMutableArray *allNames = [NSMutableArray array];

for (id person in peopleArray) {
    NSMutableString *firstName = [(NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) autorelease];
    NSMutableString *lastName = [(NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty) autorelease];
    ABMutableMultiValueRef multiValueEmail = ABRecordCopyValue(person, kABPersonEmailProperty);
    if (ABMultiValueGetCount(multiValueEmail) > 0) {
        NSString *email = [(NSString *)ABMultiValueCopyValueAtIndex(multiValueEmail, 0) autorelease];
    }

    if (![firstName length]) {
     firstName = @"";
    }
    if (![lastName length]) lastName = @"";

    [allNames addObject:[NSString stringWithFormat:@"%@ %@", firstName, lastName]];
}

人员类型为NSCFType。我可以很容易地做类似的事情:

The person type is of type NSCFType. I could easily do something like:

    if (![lastName length] && ![firstName length]) continue;

..并解决问题。我很好奇,虽然在我的地址簿中的条目是作为一个鬼。我尝试用gdb内省对象,但是不能得到任何有价值的东西。

.. and be done with the problem. I'm curious though what entry in my AddressBook is coming up as a ghost. I've tried introspecting the object with gdb, but can't get anything valuable out of it.

我想看到人的所有属性,但derefing对象到(ABPerson *)似乎没有这样做。

I'd like to see all properties for person, but derefing the object to (ABPerson*) doesn't appear to do it.

我也试过使用CFShow(person)显示它是类型CPRecord。但是,无法找到更多的文档。

I've also tried using CFShow(person) that reveals it to be type CPRecord. Can't find further documentation on that, however.

在gdb中有什么可以做进一步检查这个特定的人对象,看看它的来源从

Is there something in gdb I can do to further inspect this particular person object to see where the source of it is coming from?

推荐答案

条目可能被标记为组织记录,而不是人员记录。

The entry is probably flagged as an organization record, rather than a person record. In this case you'll have to pull out the organization name rather than the first and last name.

尝试查看属性:

kABPersonOrganizationProperty, kABPersonKindProperty

这篇关于空白字段显示在iPhone AddressBook上,如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆