title: Adding contact into ios addressbook
body: <p>I want to add contacts into my address book. I am developing an app where I have gone through many links, and I have following code, but now I am stuck.</p>
  
  <p>I have imported:</p>
  
  <pre><code>    #import &lt;AddressBook/AddressBook.h&gt;
      #import &lt;AddressBookUI/AddressBookUI.h
  </code></pre>
  
  <p>in <code>viewcontroller.m</code>:</p>
  
  <pre><code>-(IBAction)addToAddressbook:(id)sender{
  ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init];
  unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails];
  unknownPersonViewController.allowsAddingToAddressBook = YES;
  [self.navigationController pushViewController:unknownPersonViewController animated:YES];
  [unknownPersonViewController release];
  }
  
  - (ABRecordRef)buildContactDetails {
  NSLog(@"building contact details");
  ABRecordRef person = ABPersonCreate();
  CFErrorRef  error = NULL;
  
  // firstname
  ABRecordSetValue(person, kABPersonFirstNameProperty, @"Don Juan", NULL);
  
  // email
  ABMutableMultiValueRef email = ABMultiValueCreateMutable(kABMultiStringPropertyType);
  ABMultiValueAddValueAndLabel(email, @"expert.in@computer.com", CFSTR("email"), NULL);
  ABRecordSetValue(person, kABPersonEmailProperty, email, &amp;error);
  CFRelease(email);
  
  // Start of Address
  ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
  NSMutableDictionary *addressDict = [[NSMutableDictionary alloc] init];
  [addressDict setObject:@"The awesome road numba 1" forKey:(NSString *)kABPersonAddressStreetKey];
  [addressDict setObject:@"0568" forKey:(NSString *)kABPersonAddressZIPKey];
  [addressDict setObject:@"Oslo" forKey:(NSString *)kABPersonAddressCityKey];
  ABMultiValueAddValueAndLabel(address, addressDict, kABWorkLabel, NULL);
  ABRecordSetValue(person, kABPersonAddressProperty, address, &amp;error);
  [addressDict release];
  CFRelease(address);
  // End of Address
  
  if (error != NULL)
      NSLog(@"Error: %@", error);
  
  [(id)person autorelease];
  return person;
  }
  </code></pre>
  
  <p>In <code>UI</code> I have an <code>IBAction</code> button connected to <code>addToAddressbook</code>, but on click, nothing is happening - so what else to do I need to do in <code>UI</code> or in the code?</p>