In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to achieve ios address book contact attributes access, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.
ABAddressBookRef addressBook = ABAddressBookCreate ()
CFArrayRef results = ABAddressBookCopyArrayOfAllPeople (addressBook)
For (int I = 0; I < CFArrayGetCount (results); iTunes +)
{
ABRecordRef person = CFArrayGetValueAtIndex (results, I)
/ / read firstname
NSString* personName = (NSString*) ABRecordCopyValue (person, kABPersonFirstNameProperty)
If (personName! = nil)
Label.text = [label.text stringByAppendingFormat:@ "name:% @", personName]
/ / read lastname
NSString* lastname = (NSString*) ABRecordCopyValue (person, kABPersonLastNameProperty)
If (lastname! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", lastname]
/ / read middlename
NSString* middlename = (NSString*) ABRecordCopyValue (person, kABPersonMiddleNameProperty)
If (middlename! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", middlename]
/ / read prefix prefix
NSString* prefix = (NSString*) ABRecordCopyValue (person, kABPersonPrefixProperty)
If (prefix! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", prefix]
/ / read the suffix suffix
NSString* suffix = (NSString*) ABRecordCopyValue (person, kABPersonSuffixProperty)
If (suffix! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", suffix]
/ / read the name of nickname
NSString* nickname = (NSString*) ABRecordCopyValue (person, kABPersonNicknameProperty)
If (nickname! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", nickname]
/ / read firstname phonetic alphabet
NSString* firstnamePhonetic = (NSString*) ABRecordCopyValue (person,kABPersonFirstNamePhoneticProperty)
If (firstnamePhonetic! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", firstnamePhonetic]
/ / read lastname phonetic alphabet
NSString* lastnamePhonetic = (NSString*) ABRecordCopyValue (person,kABPersonLastNamePhoneticProperty)
If (lastnamePhonetic! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", lastnamePhonetic]
/ / read middlename phonetic alphabet
NSString* middlenamePhonetic = (NSString*) ABRecordCopyValue (person,kABPersonMiddleNamePhoneticProperty)
If (middlenamePhonetic! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", middlenamePhonetic]
/ / read organization Company
NSString* organization = (NSString*) ABRecordCopyValue (person, kABPersonOrganizationProperty)
If (organization! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", organization]
/ / read jobtitle work
NSString* jobtitle = (NSString*) ABRecordCopyValue (person, kABPersonJobTitleProperty)
If (jobtitle! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", jobtitle]
/ / read department department
NSString* department = (NSString*) ABRecordCopyValue (person, kABPersonDepartmentProperty)
If (department! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", department]
/ / read birthday birthday
NSDate* birthday = (NSDate*) ABRecordCopyValue (person, kABPersonBirthdayProperty)
If (birthday! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", birthday]
/ / read note memo
NSString* note = (NSString*) ABRecordCopyValue (person, kABPersonNoteProperty)
If (note! = nil)
Label.text = [label.text stringByAppendingFormat:@ "% @", note]
/ / the time when the record was first added
NSString* firstknow = (NSString*) ABRecordCopyValue (person, kABPersonCreationDateProperty)
NSLog (@ "time this record was first added% @\ n", firstknow)
/ / the time when the entry record was last modified
NSString* lastknow = (NSString*) ABRecordCopyValue (person, kABPersonModificationDateProperty)
NSLog (@ "time the record was last modified% @\ n", lastknow)
/ / get multiple values of email
ABMultiValueRef email = ABRecordCopyValue (person, kABPersonEmailProperty)
Int emailcount = ABMultiValueGetCount (email)
For (int x = 0; x < emailcount; x +)
{
/ / obtain email Label
NSString* emailLabel = (NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex (email, x))
/ / get the value of email
NSString* emailContent = (NSString*) ABMultiValueCopyValueAtIndex (email, x)
Label.text = [label.text stringByAppendingFormat:@ "% @:% @", emailLabel,emailContent]
}
/ / read address multiple values
ABMultiValueRef address = ABRecordCopyValue (person, kABPersonAddressProperty)
Int count = ABMultiValueGetCount (address)
For (int j = 0; j < count; jacks +)
{
/ / get the address Label
NSString* addressLabel = (NSString*) ABMultiValueCopyLabelAtIndex (address, j)
Label.text = [label.text stringByAppendingFormat:@ "% @", addressLabel]
/ / get the address 6 attribute under the label
NSDictionary* personaddress = (NSDictionary*) ABMultiValueCopyValueAtIndex (address, j)
NSString* country = [personaddress valueForKey: (NSString*) kABPersonAddressCountryKey]
If (country! = nil)
Label.text = [label.text stringByAppendingFormat:@ "country:% @", country]
NSString* city = [personaddress valueForKey: (NSString*) kABPersonAddressCityKey]
If (city! = nil)
Label.text = [label.text stringByAppendingFormat:@ "City:% @", city]
NSString* state = [personaddress valueForKey: (NSString*) kABPersonAddressStateKey]
If (state! = nil)
Label.text = [label.text stringByAppendingFormat:@ "province:% @", state]
NSString* street = [personaddress valueForKey: (NSString*) kABPersonAddressStreetKey]
If (street! = nil)
Label.text = [label.text stringByAppendingFormat:@ "Street:% @", street]
NSString* zip = [personaddress valueForKey: (NSString*) kABPersonAddressZIPKey]
If (zip! = nil)
Label.text = [label.text stringByAppendingFormat:@ "zip code:% @", zip]
NSString* coutntrycode = [personaddress valueForKey: (NSString*) kABPersonAddressCountryCodeKey]
If (coutntrycode! = nil)
Label.text = [label.text stringByAppendingFormat:@ "country code:% @", coutntrycode]
}
/ / get multiple values of dates
ABMultiValueRef dates = ABRecordCopyValue (person, kABPersonDateProperty)
Int datescount = ABMultiValueGetCount (dates)
For (int y = 0; y < datescount; yearly +)
{
/ / obtain dates Label
NSString* datesLabel = (NSString*) ABAddressBookCopyLocalizedLabel (ABMultiValueCopyLabelAtIndex (dates, y))
/ / get dates value
NSString* datesContent = (NSString*) ABMultiValueCopyValueAtIndex (dates, y)
Label.text = [label.text stringByAppendingFormat:@ "% @:% @", datesLabel,datesContent]
}
/ / get the kind value
CFNumberRef recordType = ABRecordCopyValue (person, kABPersonKindProperty)
If (recordType = = kABPersonKindOrganization) {
/ / it's a company
NSLog (@ "it's a company")
} else {
/ / it's a person, resource, or room
NSLog (@ "it's a person, resource, or room")
}
/ / get multiple values of IM
ABMultiValueRef instantMessage = ABRecordCopyValue (person, kABPersonInstantMessageProperty)
For (int l = 1; l < ABMultiValueGetCount (instantMessage); lump +)
{
/ / obtain IM Label
NSString* instantMessageLabel = (NSString*) ABMultiValueCopyLabelAtIndex (instantMessage, l)
Label.text = [label.text stringByAppendingFormat:@ "% @", instantMessageLabel]
/ / get the 2 attributes under the label
NSDictionary* instantMessageContent = (NSDictionary*) ABMultiValueCopyValueAtIndex (instantMessage, l)
NSString* username = [instantMessageContent valueForKey: (NSString*) kABPersonInstantMessageUsernameKey]
If (username! = nil)
Label.text = [label.text stringByAppendingFormat:@ "username:%@", username]
NSString* service = [instantMessageContent valueForKey: (NSString*) kABPersonInstantMessageServiceKey]
If (service! = nil)
Label.text = [label.text stringByAppendingFormat:@ "service:%@", service]
}
/ / read phone multiple values
ABMultiValueRef phone = ABRecordCopyValue (person, kABPersonPhoneProperty)
For (int k = 0; k
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.