iphone contact operation

    //begain lv

 

    for (id *people in peopleArray)

    {

        // fixed by Wang Yandong

NSString *firstName = (NSString *)ABRecordCopyValue((ABRecordRef)people, kABPersonFirstNameProperty);

NSString *lastName = (NSString *)ABRecordCopyValue((ABRecordRef)people, kABPersonLastNameProperty);

NSString *tmpName = [NSString stringWithFormat:@"%@%@", 

                             nil == lastName ? @"" : lastName, 

                             nil == firstName ? @"" : firstName];

int length = [tmpName length];

if(length < 2 || length > 8)

{

   [firstName release];

   [lastName release];

   continue;

}

 

 

 

 

        NSString* cellPhone =nil ;

        NSString* workPhone =nil ;

        NSString* homeAddress =nil ;

        NSString* workAddress =nil;

        NSString* homeEmail =nil;

        NSString* company =nil;

 

        //cellphone,workphone

        ABMultiValueRef mulPhone = (ABMultiValueRef) ABRecordCopyValue(people, kABPersonPhoneProperty) ;

        for(CFIndex i=0 ; i < ABMultiValueGetCount(mulPhone) ; i++)

        {

            NSString* phoneLabel = (NSString*) ABMultiValueCopyLabelAtIndex(mulPhone, i) ;

            if([phoneLabel isEqualToString:(NSString*) kABPersonPhoneMobileLabel])

            {

                cellPhone = (NSString*) ABMultiValueCopyValueAtIndex(mulPhone, i) ;

                api_log("homeAddress:%s/n", [cellPhone UTF8String]) ;

            }

            else if([phoneLabel isEqualToString:(NSString*) kABWorkLabel])

            {

                workPhone =(NSString*) ABMultiValueCopyValueAtIndex(mulPhone , i) ;

                api_log("homeAddress:%s/n", [workPhone UTF8String]) ;

            }

 

        }

        //homeaddress , workaddress

        ABMultiValueRef mulAddress =(ABMultiValueRef) ABRecordCopyValue(people, kABPersonAddressProperty) ;

        for(CFIndex i=0 ; i< ABMultiValueGetCount(mulAddress) ; i++)

        {

            NSString* addressLabel = (NSString*) ABMultiValueCopyLabelAtIndex(mulAddress, i) ;

            if([addressLabel isEqualToString:(NSString*)kABHomeLabel ])

            {

                CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(mulAddress, i);

                homeAddress = [[NSString alloc ]stringWithFormat:@"%@,%@,%@" ,CFDictionaryGetValue(dict, kABPersonAddressStreetKey) , 

                               CFDictionaryGetValue(dict, kABPersonAddressCityKey),

                               CFDictionaryGetValue(dict, kABPersonAddressCountryKey)] ;

                api_log("homeAddress:%s/n", [homeAddress UTF8String]) ;

            }

            else if([addressLabel isEqualToString:(NSString*)kABWorkLabel ])

            {

                CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(mulAddress, i);

                workAddress = [[NSString alloc ]stringWithFormat:@"%@,%@,%@" ,CFDictionaryGetValue(dict, kABPersonAddressStreetKey) , 

                               CFDictionaryGetValue(dict, kABPersonAddressCityKey),

                               CFDictionaryGetValue(dict, kABPersonAddressCountryKey)] ;

                api_log("workAddress:%s/n", [workAddress UTF8String]) ;

            }

        }

 

        //homeEmail

        ABMultiValueRef mulEmail = (ABMultiValueRef)ABRecordCopyValue(people, kABPersonEmailProperty) ;

        for(CFIndex i=0 ; i< ABMultiValueGetCount(mulEmail) ; i++)

        {

            NSString* emailLabel = (NSString*)ABMultiValueCopyLabelAtIndex(mulEmail, i) ;

            if([emailLabel isEqualToString:(NSString*)kABHomeLabel])

            {

                homeEmail = (NSString*) ABMultiValueCopyValueAtIndex(mulEmail, i) ;

                api_log("emailLabel:%s ,homeEmail:%s/n", [emailLabel UTF8String] , [homeEmail UTF8String ]) ;

            }

        }

 

        //company

        company = (NSString*)ABRecordCopyValue(people, kABPersonOrganizationProperty);

        if(company != nil)

            api_log("鍏徃:%s/n", [company UTF8String] ) ;

 

        //"CellPhone", "WorkPhone", "HomeAddress", "Email", "Company", "WorkAddress" 

        //PLCHAR16 aaa[8] = {'a', 'a', 'a'};

        PLCHAR16* core_cellphone = (PLCHAR16 *)[cellPhone cStringUsingEncoding:NSUTF16StringEncoding]; 

        //{'1','3','7','6','1','6','3','5', '9', '4', '1'};

        PLCHAR16* core_workphone = (PLCHAR16 *)[workPhone cStringUsingEncoding:NSUTF16StringEncoding];

        //{'6','0','5','8','0','8','3','3'};

        PLCHAR16* core_homeAddress = (PLCHAR16 *)[homeAddress cStringUsingEncoding:NSUTF16StringEncoding];

        //{'a','d','d','r','h','o','m','e'};

        PLCHAR16* core_email = (PLCHAR16 *)[homeEmail cStringUsingEncoding:NSUTF16StringEncoding];

        //{'a','b','c','@','g','.','c','o', 'm'};

        PLCHAR16* core_company = (PLCHAR16 *)[company cStringUsingEncoding:NSUTF16StringEncoding];

        //{'c','o','m','p','n','a','m','e'};

        PLCHAR16* core_workAddress =(PLCHAR16 *)[workAddress cStringUsingEncoding:NSUTF16StringEncoding];

        //{'a','d','d','r','c','o','m','p'};

        //         PLCHAR16 *vvv[6] = {v1, v2, v3, v4, v5, v6};

        PLCHAR16 *property[6] = {core_cellphone, core_workphone, core_homeAddress, core_email, core_company, core_workAddress};

 

 

      [cellPhone release];

      [workPhone release];

      [homeAddress release];

      [workAddress release];

      [homeEmail release];

      [company release];

 

 

        [firstName release];

[lastName release];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值