I am able to retrieve properties from an ABRecord
easily.
Ie:
NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
But I am struggling to find a way to retrieve the value of CFStringRef
constants from the record.
For instance, how would I assign an NSString
to the value of the person records kABPersonFatherLabel
? (Ie the records fathers/mother name label)
Thanks for any assistance
Nevermind, i've found the solution. For anyone else looking for a solution, see below:
ABMultiValueRef relatedNames = ABRecordCopyValue(person, kABPersonRelatedNamesProperty);
NSMutableArray *relatedNameList = [[[NSMutableArray alloc] init] autorelease];
NSDictionary *dic = [[[NSMutableDictionary alloc] init] autorelease];
for(CFIndex j = 0; j < ABMultiValueGetCount(relatedNames); j++)
{
NSString *relatedNameLabel = [(NSString*)ABMultiValueCopyLabelAtIndex(relatedNames, j) autorelease];
if ([relatedNameLabel isEqualToString:(NSString *)kABPersonFatherLabel])
{
relatedNameString = @"";
}
if (relatedNameLabel == nil)
{
relatedNameLabel = @"";
}
NSString *relatedNameString = [(NSString*)ABMultiValueCopyValueAtIndex(relatedNames, j) autorelease];
if (relatedNameString == nil)
{
relatedNameString = @"";
}
// Add the object to the dictionary
[dic setValue:(NSString *)relatedNameString forKey:relatedNameLabel];
}
You can then access the values from the dictionary by passing the CFStringRef constants (after casting to NSString)
NSString *father = [dic objectForKey:(NSString *)kABPersonFatherLabel];
NSLog( @"%@", father );