title: why is peoplePickerDelegate not getting address of the delegate right?
body: <p>The scenario is that I have more than one view that wants to invoke the Address Book. So as not to duplicate the code of the delegate in each view I have located the code in the App Delegate's header and .m file, but using an "@interface AddressBookDelegate" and "@implementation AddressBookDelegate" at the bottom of the 2 respective App Delegate fiies-</p>
  
  <pre><code>@interface AddressBookDelegate : UIViewController &lt;ABPeoplePickerNavigationControllerDelegate&gt; {
  AddressBookDelegate *addressBookDelegate;   
  }
  @property (nonatomic, retain) AddressBookDelegate *addressBookDelegate;
  @end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@implementation AddressBookDelegate
  @synthesize addressBookDelegate;
  
  - (void)peoplePickerNavigationControllerDidCancel: (ABPeoplePickerNavigationController *)peoplePicker 
  {
      [self dismissModalViewControllerAnimated:YES];
  }
  
  - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
  {   
      [super dismissModalViewControllerAnimated:YES];
  
      ...get stuff from the Address Book...   
  
      return NO;
  }
  
  - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 
                              property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
  {
      return NO;
  }
  </code></pre>
  
  <p>Then in my views I have the following code:</p>
  
  <pre><code>addressBookDelegate = (AddressBookDelegate *) [[UIApplication sharedApplication] delegate];
  
  ABPeoplePickerNavigationController *abPicker = [[ABPeoplePickerNavigationController alloc]init];    
  abPicker.peoplePickerDelegate = self.addressBookDelegate;
  [self presentModalViewController:abPicker animated:YES];
  [abPicker release];
  </code></pre>
  
  <p>The Address Book displays fine in all views. But when I take any user action that would invoke a delegate, like the Address Book's Cancel button, I crash- </p>
  
  <blockquote>
    <p>-[MyprogAppDelegate peoplePickerNavigationControllerDidCancel:]: unrecognized selector sent to instance</p>
  </blockquote>
  
  <p>It compiles clean, no Warnings. </p>
  
  <p>How do I wire-up the peoplePickerDelegate to connect to the Address Delegate code when it is not physically in the same file as the view itself ?  Thx.</p>
  
  <p>ADDED NOTE: when I use the debugger and stop on the line</p>
  
  <pre><code>abPicker.peoplePickerDelegate = addressBookDelegate;
  </code></pre>
  
  <p>in the view code, I see that the address for the addressBookDelegate is stated to be the address of the MyprogAppDelegate, not AddressBookDelegate as I might have expected. That makes me think the displacement to the address book delegate code is off within the App Delegate file.</p>
  
  <p>If the AddressBookDelegate Cancel Delegate code were say 1000 bytes into the AddressBookDelegate, my app is actually "entering" the code 1000 bytes into MyprogAppDelegate, and so crashes. So somehow I am not setting up the addressing of the AddressBookDelegate correctly. That's my take on it anyway...</p>