I am not entirely sure how to explain my problem but I will try.
So I have been trying to learn how to use delegates and protocols and ran into a problem. I have a protocol: ButtonInPopOverWasPressed, with one method:
- (void)buttonWasPressed:(NSString *)buttonValue;
I also have a main view controller and a custom popover class with the property:
@property (retain, nonatomic) id <ButtonInPopoverWasPressed> delegate;
In my main view controller I have a button and a text label. When the button is pressed it segue's to a normal popover. I then assign the segue.destinationViewController's delegate to be the main view controller like so:
[segue.destinationViewController setDelegate:self];
Then when a button from the popover is selected it is displayed in the main view's text label by calling a protocol method that the main view listens for:
[self.delegate buttonWasPressed:sender.currentTitle]; // sends the title of the button pressed to the delegate
This all works fine. My problem started when I wanted to have the popover transition to different views when a button was pressed instead of sending the information back to main view. But when I created a Navigation Controller as the popover and set the relationship to the old popover everything broke.
When I assign the delegate of the segue (shown above) it comes out on the other side as null so I completely lose my ability to pass it to other subviews and get information back to the main view. Does the Navigation Controller suck up the delegate? How do I get the delegate through the NC to the actual views?
I know this is Protocol and Delegate basics but I have looked around and can never seem to find an answer that has worked for me.