Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:54:55+00:00 2026-06-02T20:54:55+00:00

I have a method called dateSelectViewController declared in my .h file as a protocol:

  • 0

I have a method called dateSelectViewController declared in my .h file as a protocol:

@class DateSelectViewController;
@protocol DateSelectViewControllerDelegate 

- (void)dateSelectViewController:(DateSelectViewController *)sender
                         theDate:(id)stringDate;

@end

Below the protocol, I’m declaring a delegate:

@property (nonatomic, weak) id <DateSelectViewControllerDelegate> delegate;

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:

- (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];
}

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:

@interface MakePlantTVC ()<DateSelectViewControllerDelegate>
- (void)dateSelectViewController:(DateSelectViewController *)sender
                     theDate:(id)stringDate
{
    self.displayDate.text = stringDate;
    NSLog(@"delegate working");
}

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:54:56+00:00Added an answer on June 2, 2026 at 8:54 pm

    A few things came to mind

    • Have you set the delegate? It might sound stupid but when a delegate doesn’t work it’s because I forget or lose the IB connection, 90% of the time.
    • Does your weak object expire? A weak object is nil’ed – therefore you’re performing a delegate operation on ‘nothing’ – perhaps you want something more retainy or an NSNotification

    Other things I practice with delegates that might be useful

    • Use assert based programming? When you have a protocol with required functions, it’s worth asserting, ie: NSAssert(delegate, @"Error, delegate not set!");
    • Check to see if the delegate responds to the selector
    • Dispatch delegate calls asynchronously with GCD, ie:

      dispatch_async(dispatch_get_main_queue(), ^{
        if ([delegate_ respondsToSelector:@selector(updateUI:)]) 
          [delegate_ updateUI:self];
      });
      

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller which has a method called history class UsersController < ApplicationController
I have a class with a method called DataIn(int InputID, string CSVValue) , this
I have a class A which has a private method called a(). I have
How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically? Lets say i have method called
I have a method called getTheUserInput in a class which returns a String which
I have a method called startAnimation: -(void)startAnimation{ 1: self.animationTimer=[NSTimer scheduledTimerWithTimeInterval:1/60 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
I have a method called -(IBAction)setPicker:(id) sender Basically this method substitutes a keyboard into
Say I have a class called A, and in A there's a method called
I have a method called -showMoreTools: which is: - (IBAction) showMoreTools:(id)sender { UIActionSheet *popupQuery
I have a method called FormattedJoin() in a utility class called ArrayUtil . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.