如何在iphone联系人列表中的联系人信息中添加自定义字段 [英] How can I add custom fields to contacts info in iphone contact list

查看:201
本文介绍了如何在iphone联系人列表中的联系人信息中添加自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,我必须在iPhone联系人列表中添加自定义联系人。

I am developing a app in which I have to add custom contacts to iPhone Contact list.

详细说明iPhone中的每个联系人都有一组确定的字段我们可以用来保存联系信息。

To elaborate that every contact in iPhone have a definite set of fields which we can be used to save contact info.

我想知道我们是否可以

添加除了iPhone中现有选项之外的自定义字段。

如果有可能请告诉我这样做的方法,谷歌搜索它但没有找到任何东西有意义的。

If its possible please show me the way to do that, googled it but didn't found any thing meaningfull.

提前致谢。

推荐答案

来自这个

ABRecordRef aRecord = ABPersonCreate(); 
    CFErrorRef  anError = NULL; 
    ABRecordSetValue(aRecord, kABPersonFirstNameProperty, 
                     CFSTR("Jijo"), &anError); 
    ABRecordSetValue(aRecord, kABPersonLastNameProperty, 
                     CFSTR("Pulikkottil"), &anError); 
    if (anError != NULL) { 

        NSLog(@"error while creating..");
    } 
    CFStringRef firstName, lastName; 
    firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty); 
    lastName  = ABRecordCopyValue(aRecord, kABPersonLastNameProperty); 




    ABAddressBookRef addressBook; 
    CFErrorRef error = NULL; 
    addressBook = ABAddressBookCreate(); 

    BOOL isAdded = ABAddressBookAddRecord (
                            addressBook,
                            aRecord,
                             &error
    );

    if(isAdded){

        NSLog(@"added..");
    }
    if (error != NULL) {
        NSLog(@"ABAddressBookAddRecord %@", error);
    } 
    error = NULL;

    BOOL isSaved = ABAddressBookSave (
                       addressBook,
                       &error
    );

    if(isSaved){

        NSLog(@"saved..");
    }

    if (error != NULL) {
        NSLog(@"ABAddressBookSave %@", error);
    } 

    CFRelease(aRecord); 
    CFRelease(firstName); 
    CFRelease(lastName); 
    CFRelease(addressBook);

如果您需要在那里存储数据,我认为您唯一的选择是 kABPersonNoteProperty ,但我不是这方面的专家。

If you need to store data in there, I think your only option is kABPersonNoteProperty, but I'm no expert on this.

编辑: link

答案:不!

编辑:您还可以提示用户添加地址簿条目这里

you can also prompt the user to add an address book entry as done here.

这篇关于如何在iphone联系人列表中的联系人信息中添加自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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