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 6753009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:06:39+00:00 2026-05-26T13:06:39+00:00

I have standard view controller acting as the delegate for a modal view controller

  • 0

I have standard view controller acting as the delegate for a modal view controller over it.
This modal view controller is contained in a navigation controller.

After presenting the modal, and pushing another view controller onto the navigation stack, I want to pass some data back to the initial delegate view controller (that presented the modal).

Should I pass the message back up the navigation stack to the root view controller of the modal navigation controller first, and just use the delegate methods of that controller?

OR

Should I just pass the delegate property along to the nested view controller and then call the delegate directly with a separate protocol implemented. It work doing this, but I have to use

@property (nonatomic, weak) id delegate;

instead of

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

otherwise I get an incompatible type error when I pass the delegate from the preview view controller in the stack:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

NestedViewController *nest = [[NestedViewController alloc] init];

// @property id <RootViewControllerDelegate> delegate
[nest setDelegate:[self delegate]];

[[self navigationController] pushViewController:nest animated:YES];

}

What is the best practice for this kind of scenario?

Thanks

  • 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-05-26T13:06:39+00:00Added an answer on May 26, 2026 at 1:06 pm

    I would consider using notifications to decouple this. Checkout NSNoticiationCenter.

    You register for a notification in your root and publish in you child.

    http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/nsnotificationcenter_Class/Reference/Reference.html

    EXAMPLE

    In your Child object you do something like this:

    [[NSNotificationCenter defaultCenter] postNotificationName:kMyNotificationName object:self userInfo:@{ @"key" : @"value" }]];
    

    kMyNotificationName is defined in a shared place, like the pch or a Constants.h.

    In the Root you would do something like this, either in init or perhaps whenever you push the child.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myNotificationName:) name:kMyNotificationName object:nil];
    

    Don’t forget to remove observers in your dealloc or when you pop the child.

    [[NSNotificationCenter defaultCenter] removeObserver:self kMyNotificationName object:nil];
    

    Now you can handle the notification something like this:

    - (void)myNotificationName:(NSNotification *)note
    {
         NSDictionary *userInfo = [note userInfo];
    
         // Do stuff using the information passed in.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Navigation Controller in my app delegate that i am using to
Issue: I have a standard subclassed NSManagedObject (see below). I have a view controller
I have got a view controller with a UIView and a navigation controller configured
I have a standard User controller with the normal set of actions (index, show,
I have xsl view engine and want to call standard view helpers (e.g. UrlHelper.Action)
I would expect that after I push a view controller I then need to
From the standard view-based application, I found that the generated code did this: self.window.rootViewController
My app's root view controller supports any orientation but user can navigate to another
Okay, I've been struggling with this for a while now. I have a standard
Many languages have standard repositories where people donate useful libraries that they want others

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.