Appleが提供するAPIを使用してAddressBookからレコードを読み取っています。
私はまだメモリ管理に頭を悩ませているのでCFStrings
、現時点で私を混乱させています。
これは私がプロパティを取得する方法です:
//Get Basic properties
NSString* firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString* lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
NSNumber* record = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
//Build Full Name
NSString* fullName=[self fullNameWith:firstName and:lastName];
//Get Phone number and Label
ABMultiValueRef phone = ABRecordCopyValue(person, property);
//Turn identifier into index
CFIndex index = ABMultiValueGetIndexForIdentifier(phone, identifier);
//Get the value and the label using the index
NSString *value =(NSString *)ABMultiValueCopyValueAtIndex(phone, index);
CFStringRef label = ABMultiValueCopyLabelAtIndex(phone, index);
//Get the localized value of hte label
NSString * localizedLabel = (NSString *)ABAddressBookCopyLocalizedLabel(label);
その後、値を使用しますが、唯一のことは、値を解放する必要があるかどうかわからないことです。
メモリ管理をよりよく理解するのに役立つ、または正しい方向を示す答えをいただければ幸いです。
ありがとうございました!