Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this delegate - protocol not responding?
    primarykey
    data
    text
    <p>I have a method called dateSelectViewController declared in my .h file as a protocol:</p> <pre><code>@class DateSelectViewController; @protocol DateSelectViewControllerDelegate - (void)dateSelectViewController:(DateSelectViewController *)sender theDate:(id)stringDate; @end </code></pre> <p>Below the protocol, I'm declaring a delegate:</p> <pre><code>@property (nonatomic, weak) id &lt;DateSelectViewControllerDelegate&gt; delegate; </code></pre> <p>and in the implementation file, I synthesize the delegate, and I send a message to the delegate when the done button is pressed in my view:</p> <pre><code>- (IBAction)DonePressed:(id)sender { NSDate *chosen = [datePicker date]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MM/dd/yyyy"]; NSString *formatedDate = [formatter stringFromDate:chosen]; //sending a message to the delegate [self.delegate dateSelectViewController:self theDate:formatedDate]; [self.navigationController popViewControllerAnimated:YES]; } </code></pre> <p>In the .h file that's being delegated to, I'm importing the delegators .h file. And in the .m file I'm conforming to the protocol:</p> <pre><code>@interface MakePlantTVC ()&lt;DateSelectViewControllerDelegate&gt; - (void)dateSelectViewController:(DateSelectViewController *)sender theDate:(id)stringDate { self.displayDate.text = stringDate; NSLog(@"delegate working"); } </code></pre> <p>For some reason the this is working at all. When the done button is pressed in my delegators class, the button does as it's supposed to and pops the view controller but it's like the message is never sent to the delegate. At first I thought I could be sending a message to nil but its' of type id, so that shouldn't be the case. Why is the message not being sent? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload