Guest User

Untitled

a guest
Apr 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (IBAction)go:(id)sender {
  2.     NSLog(@"sender called");
  3.    
  4.     ABRecordRef record = ABPersonCreate();
  5.    
  6.     ABNewPersonViewController *ctr = [[ABNewPersonViewController alloc] init];
  7.     CFDataRef cfData = (CFDataRef)UIImagePNGRepresentation([UIImage imageNamed: @"a.png"]);
  8.     CFErrorRef err1;
  9.     CFErrorRef err2;
  10.     ABPersonSetImageData(record, cfData, &err1);
  11.     ABRecordSetValue(record, kABPersonFirstNameProperty, CFSTR("Lucian"), &err2);
  12.     ABRecordSetValue(record, kABPersonLastNameProperty, CFSTR("Boboc"), &err2);
  13.     ABRecordSetValue(record, kABPersonEmailProperty, CFSTR("boboc.lucian@mac.com"), NULL);
  14.     ctr.newPersonViewDelegate = self;
  15.     ctr.displayedPerson = record;
  16.    
  17.     CFDictionaryRef dictionary = CreateDictionary();
  18.     ABMultiValueIdentifier identifier;
  19.     ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
  20.     ABMultiValueAddValueAndLabel(address, dictionary, kABHomeLabel, &identifier);
  21.    
  22.  
  23.     CFStringRef label = kABPersonPhoneMobileLabel;
  24.     CFStringRef phoneNr = CFSTR("0743038888");
  25.     ABMultiValueIdentifier identifier2;
  26.     ABMutableMultiValueRef phone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
  27.     ABMultiValueAddValueAndLabel(phone, phoneNr, label, &identifier2);
  28.    
  29.     ABRecordSetValue(record, kABPersonAddressProperty, address, NULL);
  30.    
  31.     UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:ctr];  
  32.     NSLog(@"nav: %@, ctr: %@",controller, ctr);
  33.     [self presentModalViewController: controller animated: YES];
  34.  
  35.     [ctr release];
  36.     [controller release];
  37.    
  38.     if(dictionary)
  39.         CFRelease(dictionary);
  40.     if(record)
  41.         CFRelease(record);
  42.     if(address != NULL)
  43.         CFRelease(address);
  44.     if(phone)
  45.         CFRelease(phone);
  46.    
  47. }
Add Comment
Please, Sign In to add comment