网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 iphone取得用户的电话本代码
内容
    //取得用户的电话本 代码
    -(void)getuseraddressbook{
    //redic = {7:数码先锋,1:最爱街拍} //打开电话本数据库
    abaddressbookref addressref=abaddressbookcreate();
    //返回所有联系人到一个数组中
    cfarrayref personarray = abaddressbookcopyarrayofallpeople(addressref);
    nsmutabledictionary *jsondictionary = [[nsmutabledictionary alloc]init];
    //循环读取每个联系人
    for (int i =0;i< p>
    //得到当前联系人
    abrecordref personref=cfarraygetvalueatindex(personarray, i); //==============================================================================
    cfstringref firstname=abrecordcopyvalue(personref, kabpersonfirstnameproperty);
    cfstringref lastname=abrecordcopyvalue(personref, kabpersonlastnameproperty);
    //cfstringref userphone = abrecordcopyvalue(personref,kabpersonphoneproperty );
    nsstring *allname;if([firstname isequaltostring:@]||firstname==nil){if([lastname isequaltostring:@]||lastname==nil){
    allname=@空;
    }
    }else if([lastname isequaltostring:@]||lastname==nil){allname=[nsstring stringwithformat:@];
    }else if([firstname isequaltostring:@]||firstname==nil){allname=[nsstring stringwithformat:@>];
    }else{
    allname=[nsstring stringwithformat:@];
    } // nslog(@); //============================================================================== // nslog(@); //用于循环计数 int j; //用于保存有多项的属性值 abmultivalueref values ; //==============================================================================
    //循环读出该项的所有值,如果需要修改读出其它具有多项值的属性,只需修改kab...property //具有多项值的属性有电话,地址,email
    values = (abmultivalueref) abrecordcopyvalue(personref , kabpersonphoneproperty);
    //nslog(@);
    nsstring *getphonenum;
    for(j = 0 ;j < abmultivaluegetcount(values); j++) {
    getphonenum = [nsstring stringwithformat:@%@, (nsstring *)abmultivaluecopyvalueatindex(values, j)]; }if(abmultivaluegetcount(values)==0){
    getphonenum=@空;
    }//nslog(@); // values = (abmultivalueref) abrecordcopyvalue(personref , kabpersonemailproperty);// for( j = 0 ;j < abmultivaluegetcount(values); j++)// { // nslog(@1-%@, (nsstring *)abmultivaluecopyvalueatindex(values, j));// // }// // values = (abmultivalueref) abrecordcopyvalue(personref , kabpersonaddressproperty);// for( j = 0 ;j < abmultivaluegetcount(values); j++)// { // nslog(@2-%@, (nsstring *)abmultivaluecopyvalueatindex(values, j));// // }[jsondictionary setobject:getphonenum forkey:allname] ; //============================================================================== }
    //nslog(@); nsstring *str = [jsondictionary jsonrepresentation];nslog(@); // nsstring *d = [str jsonvalue];[jsondictionary release];
    // nsstring *str = [jsondictionary jsonrepresentation];// nsmutabledictionary *d = [jsondictionary jsonvalue];// nslog(@%@ , [d description]); // [dlist release];//nslog(@);}
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/18 4:17:45