如何将地址簿中的数据同步到服务器?

时间:2013-08-22 12:33:30

标签: iphone response addressbook

大家好我有一个包含电子邮件的远程用户数据库。现在我的应用程序必须列出通讯录中的所有联系人电子邮件,并检查用户是否已在数据库中注册。我正在考虑发送所有电子邮件并检查数据库并回复数据并将其显示在uitableview中。但这是正确的方法吗?如果我们要检查2000或3000个电子邮件地址,我正在考虑带宽和加载时间?

1 个答案:

答案 0 :(得分:0)

使用ABPeoplePickerNavigationController委托使用kABPersonEmail属性从联系人列表中检索电子邮件。

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person {

    CFStringRef emailName = nil;
    ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
    emailName = ABMultiValueCopyValueAtIndex(emails, 0);

    /*
        Here make code for DB
        1) Make email Field of DB unique.
        2) select query like:
            select * from tblContact where email = emailName;

           get count of Record set.
        3) if record set count == 0 then 
               insert emailName in tblContact using insert Query.
           else
               Do nothing
    */
    if(emailName)
         CFRelease(emailName);
    if(emails)
         CFRelease(emails);

    return NO;
}