将iPhone联系人列表的所有电子邮件ID提取到iPhone应用程序中 [英] Fetch all email-id of contact list of iphone in to the iphone app

查看:65
本文介绍了将iPhone联系人列表的所有电子邮件ID提取到iPhone应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取iPhone联系人列表中所有联系人的电子邮件ID.然后将所有电子邮件ID显示在应用程序的选择器视图中.请给我一些解决此问题的想法.感谢所有人,

I need to fetch all email id's of contacts which is present in contact list of iPhone. and then all email id to show in picker View in app. please give me ideas to solve this problem. Thanks to all,

推荐答案

检查一下,

    ABAddressBookRef _addressBookRef = ABAddressBookCreate();
    NSArray* allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(_addressBookRef);

   NSMutableDictionary  *contactsInformation = [[NSMutableDictionary alloc] initWithCapacity:[allPeople count]];

    for (id record in allPeople) 
    {
        NSMutableDictionary *propertyList = [[NSMutableDictionary alloc] init];


        CFTypeRef emailProp = ABRecordCopyValue((ABRecordRef)record, kABPersonEmailProperty);
        NSString *email = [((NSArray *)ABMultiValueCopyArrayOfAllValues(emailProp)) objectAtIndex:0 ];
        if (!email) {
            email = @"";  
        }

        [propertyList setObject:email forKey:@"Email"];

        [contactsInformation setObject:propertyList forKey:[NSNumber numberWithInt:ABRecordGetRecordID((ABRecordRef)record)]];

        [propertyList release];
    }
    CFRelease(_addressBookRef);
    [allPeople release];
    allPeople = nil;

这篇关于将iPhone联系人列表的所有电子邮件ID提取到iPhone应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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