Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created January 10, 2011 04:13
Show Gist options
  • Save kwylez/772344 to your computer and use it in GitHub Desktop.
Save kwylez/772344 to your computer and use it in GitHub Desktop.
/**
* Assume that first name is the first instance of characters before the first
* " ". Everything else will be considered the last name.
*/
NSArray *nameSplitArray = [self.employee.name componentsSeparatedByString:@" "];
NSMutableArray *nameSplitMutableArray = [nameSplitArray mutableCopy];
[nameSplitMutableArray removeObjectAtIndex:0];
// set the first and last name properties
ABRecordSetValue(person, kABPersonFirstNameProperty, (CFStringRef)[nameSplitArray objectAtIndex:0], &error);
ABRecordSetValue(person, kABPersonLastNameProperty, (CFStringRef)[nameSplitMutableArray componentsJoinedByString:@","], &error);
[nameSplitMutableArray release];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment