Created
November 17, 2012 01:14
-
-
Save sforteln/4092384 to your computer and use it in GitHub Desktop.
This file contains 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
-(void) addFakeContacts{ | |
ABAddressBookRef addressBook = ABAddressBookCreate(); | |
// create 200 random contacts | |
for (int i = 201; i < 400; i++) | |
{ | |
// create an ABRecordRef | |
ABRecordRef record = ABPersonCreate(); | |
ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABStringPropertyType); | |
NSString *email = [NSString stringWithFormat:@"%i@%ifoo.com", i, i]; | |
ABMultiValueAddValueAndLabel(multi, (__bridge CFTypeRef)(email), kABHomeLabel, NULL); | |
NSString *fname = [NSString stringWithFormat:@"Name %i", i]; | |
NSString *lname = [NSString stringWithFormat:@"Last %i", i]; | |
// add the first name | |
ABRecordSetValue(record, kABPersonFirstNameProperty, (__bridge CFTypeRef)(fname), NULL); | |
// add the last name | |
ABRecordSetValue(record, kABPersonLastNameProperty, (__bridge CFTypeRef)(lname), NULL); | |
// add the home email | |
ABRecordSetValue(record, kABPersonEmailProperty, multi, NULL); | |
// add the record | |
ABAddressBookAddRecord(addressBook, record, NULL); | |
} | |
// save the address book | |
ABAddressBookSave(addressBook, NULL); | |
// release | |
CFRelease(addressBook); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment