Created
January 10, 2015 16:23
-
-
Save benjaminsnorris/9336d9c16835a9dc40a1 to your computer and use it in GitHub Desktop.
Get multiple values from selected contacted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSDictionary *)getMultipleValuesForPerson:(ABRecordRef)person forProperty:(ABPropertyID)property sanitizeToNumbers:(BOOL)sanitize { | |
NSMutableDictionary *mutableValuesWithLabels = [NSMutableDictionary dictionary]; | |
ABMultiValueRef values = ABRecordCopyValue(person, property); | |
if (values && ABMultiValueGetCount(values) > 0) | |
{ | |
for (CFIndex index = 0; index < ABMultiValueGetCount(values); index++) { | |
NSString *label = CFBridgingRelease(ABMultiValueCopyLabelAtIndex(values, index)); | |
NSString *value = CFBridgingRelease(ABMultiValueCopyValueAtIndex(values, index)); | |
if (sanitize) { | |
value = [[value componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""]; | |
} | |
[mutableValuesWithLabels setObject:value forKey:label]; | |
} | |
CFRelease(values); | |
} | |
return mutableValuesWithLabels; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment