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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:30:21+00:00 2026-05-22T22:30:21+00:00

I have a NavigationController that present a view (ShoppingController) with a button which one

  • 0

I have a NavigationController that present a view (ShoppingController) with a button which one I call a ModalViewController :

    AddProductController *maView = [[AddProductController alloc] init];
maView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:maView animated:YES];

When I want exchange data from my modal view to his parent, I have an error because [self parentViewController] refer to my NavigationController and not my ShoppingController.

How can I send data from my ModalView AddProductController to my caller ShoppingController ?

  • 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-22T22:30:22+00:00Added an answer on May 22, 2026 at 10:30 pm

    You could use the delegate pattern.

    In your AddProductController class, when handling the button tap, you can then send a message to its delegate, which you set as your ShoppingController.

    So, in AddProductController:

    -(void)buttonHandler:(id)sender {
        // after doing some stuff and handling the button tap, i check to see if i have a delegate.
        // if i have a delegate, then check if it responds to a particular selector, and if so, call the selector and send some data
        // the "someData" object is the data you want to pass to the caller/delegate
        if (self.delegate && [self.delegate respondsToSelector:@selector(receiveData:)])
            [self.delegate performSelector:@selector(receiveData:) withObject:someData];
    }
    

    Then, in ShoppingController (and don’t forget to release maView):

    -(void)someMethod {
        AddProductController *maView = [[AddProductController alloc] init];
        maView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        maView.delegate = self;
        [self presentModalViewController:maView animated:YES];
        [maView release];
    }
    
    -(void)receiveData:(id)someData {
         // do something with someData passed from AddProductController
    }
    

    If you want to get fancy, you can make receiveData: part of a protocol. Then, your ShoppingController can implement the protocol, and instead of checking with [self.delegate respondsToSelector:@selector(x)], you check that [self.delegate conformsToProtocol:@protocol(y)].

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

Sidebar

Related Questions

I have a UITableView which lies in a NavigationController that is in a popover.
I have a UITableView , to which I add a Header-View, designed in InterfaceBuilder.
I have a dilema, I want to present to the user a semi-transparent view.
I present a modal view controller which is a tab bar controller with a
I have a script that appends some rows to a table. One of the
I have View Controller with a (navigation controller) that can flip between 2 views
I have an app which consists of three layers of view controllers: UITabBarController =>
I have a table view which presents a UIViewController whenever a row is tapped
I have a view controller that is used to populate data from the core
I have a view controller that i'm trying to push onto the navigation stack.

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.