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

  • SEARCH
  • Home
  • 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 8880129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:06:24+00:00 2026-06-14T20:06:24+00:00

I am trying to make a custom protocol that i hope somebody might help

  • 0

I am trying to make a custom protocol that i hope somebody might help with.

I have a mainViewController (mainVC) that has a label. That label needs to be updated with a string when i press a button in edwwVC.

I am using ARC and storyboard.

The problem is when i press the Done Button on the edwwVC, the “done” method is called BUT the delegate method is not called in mainVC.
Whereas, if i call the done method VIA the mainVC, then the done method is called AND the delegate method. So I can see the connection is there, I just do not understand why the delegate method is not called when i press the done button in the edwwVC.

I imagine it has something to do with the init of the edwwVC. Because it is already initiated by storyboard, so it looks to me as if I am initializing it again the in the viewDidLoad method of the mainVC. But that is how far i got 🙂

Thanks in advance!

edwwVC.h

#import <UIKit/UIKit.h>
#import "IIViewDeckController.h"

@class EDWWViewController;

@protocol EDWWViewControllerDelegate <NSObject>;
@optional
- (void)edwwVCDidFinish:(EDWWViewController *)edwwVC;
@end

@interface EDWWViewController : UIViewController <IIViewDeckControllerDelegate> {
__weak  id<EDWWViewControllerDelegate> delegate;
NSMutableArray *edwwPoints;
}

@property (weak) id<EDWWViewControllerDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITableView *theTableView;
@property (strong, nonatomic)     NSString *testString;
- (IBAction)done:(id)sender;
- (IBAction)add:(id)sender;
@end

edwwVC.m:

#pragma mark - delegate method
- (IBAction)done:(id)sender {
testString = @"This is the test string!";
[delegate edwwVCDidFinish:self];
[self.viewDeckController closeRightViewAnimated:YES];
NSLog(@"Done pressed");
}

MainVC.m:

- (void)viewDidLoad
{
[super viewDidLoad];
edwwViewController = [[EDWWViewController alloc] init];
edwwViewController.delegate = self;
}  

- (void)edwwVCDidFinish:(EDWWViewController *)edwwVC {    
edwwLabel.text= edwwVC.testString;    
NSLog(@"delegate method called");
}
  • 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-14T20:06:25+00:00Added an answer on June 14, 2026 at 8:06 pm

    Remove the line …

    __weak  id<EDWWViewControllerDelegate> delegate;
    

    From the .h and change the line…

    [delegate edwwVCDidFinish:self];
    

    to…

    [self.delegate edwwVCDidFinish:self];
    

    In the .m.

    That should sort it.

    The way you have it set up the ivar delegate is not the same as the property delegate (which is actually an ivar called _delegate) (thanks @Joris Kluivers, just adding for clarity). They are pointing to different things.

    If you add a breakpoint where you are calling the delegate method I think you’ll find that delegate is nil. Whereas _delegate (or self.delegate) is not nil.

    ::EDIT::

    Ahh… just spotted the second bit too.

    If you are setting up the edwwvc in storyboard then you should be alloc initing it too.

    If you are segue-ing to the edwwvc then you should intercept the segue in mainVC.m like this…

    - (void)prepareForSegue: //blah the rest of the name...
    {
        if ([segue.identifier isEqualToString:@"the name of your segue"])
        {
            EDWWViewController *controller = segue.destinationViewController;
    
            controller.delegate = self;
        }
    }
    

    This will take the controller that you are pushing to from the storyboard and set the delegate to it.

    :: ANOTHER EDIT ::

    If EDWWVC is inside a containerViewController then you can do this inside viewDidLoad in MainVC.m…

    - (void)viewDidLoad
    {
        // other stuff...
    
        for (UIViewController *controller in self.childViewControllers) {
            if ([controller isKindOfClass:[EDWWViewController class]]) {
                EDWWViewController *edwwvc = (EDWWViewController*)controller;
    
                eddwvc.delegate = self;
            }
        }
    }
    

    You may find this code has to go in viewDidAppear or something but I think viewDidLoad shouldd work just fine.

    You may actually be able to set the delegate property directly by using the storyboard to (but I’m not 100% certain on this).

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

Sidebar

Related Questions

Im trying to make a custom view that will have a dynamic number of
I'm trying to make a custom text view that has the font set from
I could use some help with custom delegates. I'm trying to make a protocol
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
Trying to make a custom :confirm message for a rails form that returns data
I'm trying to make a custom infowindow. Version = 2. I have added my
I'm trying to make a custom converter that inherits from DependencyObject , but it
I am trying to make a custom Calendar view and for that I use
I'm trying to make my custom filter work... I have the following code in
I'm trying to make a custom FxCop rule that will test for calls to

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.