0

I'm using ABNewPersonViewController to add a new contact. However, I want to ensure that the user inputs some fields. How do I achieve this?

I don't see any help from ABNewPersonControllerDelegate or from ABNewPersonViewController.

Dunes Buggy
  • 1,779
  • 1
  • 21
  • 41
  • 1
    if( field.text == @"") ? – Watsche Apr 24 '14 at 14:16
  • Are you suggesting that I check this in the delegate method? And if it doesn't match my criteria then don't allow to dismiss the controller ? – Dunes Buggy Apr 24 '14 at 14:17
  • 1
    You need add yourTextFiled.delegate = self. after that, catch delegate textFieldShouldBeginEditing or textFieldDidBeginEditing. When user presses OK button, let check condition: if(username.text.length>0) etc. – nmh Apr 24 '14 at 14:21
  • @Watsche You can't use `== @""` to see if an `NSString` is the empty string. – rmaddy Apr 24 '14 at 14:32
  • 1
    @nmh What text field? The question is about creating a new contact. – rmaddy Apr 24 '14 at 14:33

1 Answers1

0

Your only real choice is to implement the ABNewPersonViewControllerDelegate delegate method newPersonViewController:didCompleteWithNewPerson:. You will be given the ABRecordRef of the new contact. You will then need to load that contact and see if there are values. If not, you can choose to delete the new contact.

rmaddy
  • 314,917
  • 42
  • 532
  • 579