Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (IBAction)go:(id)sender {
- NSLog(@"sender called");
- ABRecordRef record = ABPersonCreate();
- ABNewPersonViewController *ctr = [[ABNewPersonViewController alloc] init];
- CFDataRef cfData = (CFDataRef)UIImagePNGRepresentation([UIImage imageNamed: @"a.png"]);
- CFErrorRef err1;
- CFErrorRef err2;
- ABPersonSetImageData(record, cfData, &err1);
- ABRecordSetValue(record, kABPersonFirstNameProperty, CFSTR("Lucian"), &err2);
- ABRecordSetValue(record, kABPersonLastNameProperty, CFSTR("Boboc"), &err2);
- ABRecordSetValue(record, kABPersonEmailProperty, CFSTR("boboc.lucian@mac.com"), NULL);
- ctr.newPersonViewDelegate = self;
- ctr.displayedPerson = record;
- CFDictionaryRef dictionary = CreateDictionary();
- ABMultiValueIdentifier identifier;
- ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
- ABMultiValueAddValueAndLabel(address, dictionary, kABHomeLabel, &identifier);
- CFStringRef label = kABPersonPhoneMobileLabel;
- CFStringRef phoneNr = CFSTR("0743038888");
- ABMultiValueIdentifier identifier2;
- ABMutableMultiValueRef phone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
- ABMultiValueAddValueAndLabel(phone, phoneNr, label, &identifier2);
- ABRecordSetValue(record, kABPersonAddressProperty, address, NULL);
- UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:ctr];
- NSLog(@"nav: %@, ctr: %@",controller, ctr);
- [self presentModalViewController: controller animated: YES];
- [ctr release];
- [controller release];
- if(dictionary)
- CFRelease(dictionary);
- if(record)
- CFRelease(record);
- if(address != NULL)
- CFRelease(address);
- if(phone)
- CFRelease(phone);
- }
Add Comment
Please, Sign In to add comment