Monday, December 30, 2013

invalid conversion from 'const void *' to 'const __ CFString *' solved

/ / Get all people info from the address book
ABAddressBookRef addressBook = ABAddressBookCreate ();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople (addressBook) ;/ / this is a reference to an array
for (int i = 0; i / / Parse each person of addressbook
ABRecordRef record = CFArrayGetValueAtIndex (people, i) ;/ / remove a record
Properties / / The following are unique, that a person has only one FirstName, an Organization. . .
CFStringRef firstName = ABRecordCopyValue (record, kABPersonFirstNameProperty);
here always error invalid conversion from 'const void *' to 'const __ CFString *'
CFStringRef lastName = ABRecordCopyValue (record, kABPersonLastNameProperty);
CFStringRef company = ABRecordCopyValue (record, kABPersonOrganizationProperty);
CFStringRef department = ABRecordCopyValue (record, kABPersonDepartmentProperty);
CFStringRef job = ABRecordCopyValue (record, kABPersonJobTitleProperty);
/ / "CFStringRef" This type is also a reference, you can turn into NSString *
NSlog ((NSString *) firstName);
/ / ......
/ / All of these applications are to be released, the manual is to say "you are responsible to release it"
(FirstName == NULL): CFRelease (firstName);
?(LastName == NULL): CFRelease (lastName);
?(Company == NULL): CFRelease (company);
?(Department == NULL): CFRelease (department);
?(Job == NULL): CFRelease (job);
?/ / .......
/ / Some attributes are not unique, such a person has more than one phone: the phone, the main telephone and fax. . .
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable (kABMultiStringPropertyType);

No comments:

Post a Comment