001 | ABAddressBookRefaddressBook=ABAddressBookCreate(); |
003 | CFArrayRefresults=ABAddressBookCopyArrayOfAllPeople(addressBook); |
005 | for ( int i=0;i<CFArrayGetCount(results);i++) |
007 | ABRecordRefperson=CFArrayGetValueAtIndex(results,i); |
009 | NSString*personName=(NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty); |
011 | textView.text=[textView.textstringByAppendingFormat:@ "\n姓名:%@\n" ,personName]; |
013 | NSString*lastname=(NSString*)ABRecordCopyValue(person,kABPersonLastNameProperty); |
015 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,lastname]; |
017 | NSString*middlename=(NSString*)ABRecordCopyValue(person,kABPersonMiddleNameProperty); |
019 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,middlename]; |
021 | NSString*prefix=(NSString*)ABRecordCopyValue(person,kABPersonPrefixProperty); |
023 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,prefix]; |
025 | NSString*suffix=(NSString*)ABRecordCopyValue(person,kABPersonSuffixProperty); |
027 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,suffix]; |
029 | NSString*nickname=(NSString*)ABRecordCopyValue(person,kABPersonNicknameProperty); |
031 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,nickname]; |
033 | NSString*firstnamePhonetic=(NSString*)ABRecordCopyValue(person,kABPersonFirstNamePhoneticProperty); |
034 | if (firstnamePhonetic!=nil) |
035 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,firstnamePhonetic]; |
037 | NSString*lastnamePhonetic=(NSString*)ABRecordCopyValue(person,kABPersonLastNamePhoneticProperty); |
038 | if (lastnamePhonetic!=nil) |
039 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,lastnamePhonetic]; |
041 | NSString*middlenamePhonetic=(NSString*)ABRecordCopyValue(person,kABPersonMiddleNamePhoneticProperty); |
042 | if (middlenamePhonetic!=nil) |
043 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,middlenamePhonetic]; |
045 | NSString*organization=(NSString*)ABRecordCopyValue(person,kABPersonOrganizationProperty); |
047 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,organization]; |
049 | NSString*jobtitle=(NSString*)ABRecordCopyValue(person,kABPersonJobTitleProperty); |
051 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,jobtitle]; |
053 | NSString*department=(NSString*)ABRecordCopyValue(person,kABPersonDepartmentProperty); |
055 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,department]; |
057 | NSDate*birthday=(NSDate*)ABRecordCopyValue(person,kABPersonBirthdayProperty); |
059 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,birthday]; |
061 | NSString*note=(NSString*)ABRecordCopyValue(person,kABPersonNoteProperty); |
063 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,note]; |
065 | NSString*firstknow=(NSString*)ABRecordCopyValue(person,kABPersonCreationDateProperty); |
066 | NSLog(@ "第一次添加该条记录的时间%@\n" ,firstknow); |
068 | NSString*lastknow=(NSString*)ABRecordCopyValue(person,kABPersonModificationDateProperty); |
069 | NSLog(@ "最后一次修改該条记录的时间%@\n" ,lastknow); |
072 | ABMultiValueRefemail=ABRecordCopyValue(person,kABPersonEmailProperty); |
073 | int emailcount=ABMultiValueGetCount(email); |
074 | for ( int x=0;x<emailcount;x++) |
077 | NSString*emailLabel=(NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(email,x)); |
079 | NSString*emailContent=(NSString*)ABMultiValueCopyValueAtIndex(email,x); |
080 | textView.text=[textView.textstringByAppendingFormat:@ "%@:%@\n" ,emailLabel,emailContent]; |
083 | ABMultiValueRefaddress=ABRecordCopyValue(person,kABPersonAddressProperty); |
084 | int count=ABMultiValueGetCount(address); |
086 | for ( int j=0;j<count;j++) |
089 | NSString*addressLabel=(NSString*)ABMultiValueCopyLabelAtIndex(address,j); |
090 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,addressLabel]; |
092 | NSDictionary*personaddress=(NSDictionary*)ABMultiValueCopyValueAtIndex(address,j); |
093 | NSString*country=[personaddressvalueForKey:(NSString*)kABPersonAddressCountryKey]; |
095 | textView.text=[textView.textstringByAppendingFormat:@ "国家:%@\n" ,country]; |
096 | NSString*city=[personaddressvalueForKey:(NSString*)kABPersonAddressCityKey]; |
098 | textView.text=[textView.textstringByAppendingFormat:@ "城市:%@\n" ,city]; |
099 | NSString*state=[personaddressvalueForKey:(NSString*)kABPersonAddressStateKey]; |
101 | textView.text=[textView.textstringByAppendingFormat:@ "省:%@\n" ,state]; |
102 | NSString*street=[personaddressvalueForKey:(NSString*)kABPersonAddressStreetKey]; |
104 | textView.text=[textView.textstringByAppendingFormat:@ "街道:%@\n" ,street]; |
105 | NSString*zip=[personaddressvalueForKey:(NSString*)kABPersonAddressZIPKey]; |
107 | textView.text=[textView.textstringByAppendingFormat:@ "邮编:%@\n" ,zip]; |
108 | NSString*coutntrycode=[personaddressvalueForKey:(NSString*)kABPersonAddressCountryCodeKey]; |
110 | textView.text=[textView.textstringByAppendingFormat:@ "国家编号:%@\n" ,coutntrycode]; |
114 | ABMultiValueRefdates=ABRecordCopyValue(person,kABPersonDateProperty); |
115 | int datescount=ABMultiValueGetCount(dates); |
116 | for ( int y=0;y<datescount;y++) |
119 | NSString*datesLabel=(NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(dates,y)); |
121 | NSString*datesContent=(NSString*)ABMultiValueCopyValueAtIndex(dates,y); |
122 | textView.text=[textView.textstringByAppendingFormat:@ "%@:%@\n" ,datesLabel,datesContent]; |
125 | CFNumberRefrecordType=ABRecordCopyValue(person,kABPersonKindProperty); |
126 | if (recordType==kABPersonKindOrganization){ |
128 | NSLog(@ "it'sacompany\n" ); |
130 | //it'saperson,resource,orroom |
131 | NSLog(@ "it'saperson,resource,orroom\n" ); |
136 | ABMultiValueRefinstantMessage=ABRecordCopyValue(person,kABPersonInstantMessageProperty); |
137 | for ( int l=1;l<ABMultiValueGetCount(instantMessage);l++) |
140 | NSString*instantMessageLabel=(NSString*)ABMultiValueCopyLabelAtIndex(instantMessage,l); |
141 | textView.text=[textView.textstringByAppendingFormat:@ "%@\n" ,instantMessageLabel]; |
143 | NSDictionary*instantMessageContent=(NSDictionary*)ABMultiValueCopyValueAtIndex(instantMessage,l); |
144 | NSString*username=[instantMessageContentvalueForKey:(NSString*)kABPersonInstantMessageUsernameKey]; |
146 | textView.text=[textView.textstringByAppendingFormat:@ "username:%@\n" ,username]; |
148 | NSString*service=[instantMessageContentvalueForKey:(NSString*)kABPersonInstantMessageServiceKey]; |
150 | textView.text=[textView.textstringByAppendingFormat:@ "service:%@\n" ,service]; |
154 | ABMultiValueRefphone=ABRecordCopyValue(person,kABPersonPhoneProperty); |
155 | for ( int k=0;k<ABMultiValueGetCount(phone);k++) |
158 | NSString*personPhoneLabel=(NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phone,k)); |
160 | NSString*personPhone=(NSString*)ABMultiValueCopyValueAtIndex(phone,k); |
162 | textView.text=[textView.textstringByAppendingFormat:@ "%@:%@\n" ,personPhoneLabel,personPhone]; |
166 | ABMultiValueRefurl=ABRecordCopyValue(person,kABPersonURLProperty); |
167 | for ( int m=0;m<ABMultiValueGetCount(url);m++) |
170 | NSString*urlLabel=(NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(url,m)); |
172 | NSString*urlContent=(NSString*)ABMultiValueCopyValueAtIndex(url,m); |
174 | textView.text=[textView.textstringByAppendingFormat:@ "%@:%@\n" ,urlLabel,urlContent]; |
178 | NSData*image=(NSData*)ABPersonCopyImageData(person); |
181 | UIImageView*myImage=[[UIImageViewalloc]initWithFrame:CGRectMake(200,0,50,50)]; |
182 | [myImagesetImage:[UIImageimageWithData:image]]; |
184 | [textViewaddSubview:myImage]; |
191 | CFRelease(addressBook); |
}
更多0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理