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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:40:59+00:00 2026-06-14T21:40:59+00:00

I came across an interesting problem, i have main ViewController let’s call him MainVC

  • 0

I came across an interesting problem, i have main ViewController let’s call him MainVC with navigationController and i am doing performSegueWithIdentifier from him to Mine second ViewController let’s call him SecVC. so when i am trying to do the popViewControllerAnimated i want to pass some data from the SecVC to the MainVc.. i know i can do it with appDelegate Param or with singletons class but my question is : can i do it with more Elegant solution? like i use prepareForSegue and use local parmeters..

Thank you…

  • 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-14T21:41:00+00:00Added an answer on June 14, 2026 at 9:41 pm

    The best way to do it is by using a delegate.

    //SecVCDelegate.h

    #import <Foundation/Foundation.h>
    
    @protocol SecVSDelegate <NSObject>
    
    @optional
    - (void)secVCDidDismisWithData:(NSObject*)data;
    @end
    

    //SecVC.h

    #import <UIKit/UIKit.h>
    #import "SecVSDelegate.h"
    
    @interface SecVC : UIViewController
    
    /** Returns the delegate */
    @property (nonatomic, assign)   id<SecVSDelegate> delegate;
    
    @end
    

    //SecVC.M

    ...
    
    - (void) dealloc
    {
    ...
    delegate = nil
    ...
    }
    

    When ever you popViewControllerAnimated, right after it (or before it) you do this

    if(_delegate && [_delegate respondsToSelector:@selector(secVCDidDismisWithData:)])
    {
    [_delegate secVCDidDismisWithData:myDataObject];
    }
    

    And in the MainVC you must be certain that you implement the delegate function
    //MainVC.m

    - (void)secVCDidDismisWithData
    {
    //do whatever you want with the data
    }
    

    To avoid any warnings you must tell that the MainVC class implements the delegate like this:

    //MainVC.h

    #import "SecVCDelegate.h"
    ...
    @interface MainVC : UIViewController <SecVCDelegate>
    ...
    secVCInstance.delegate = self;
    [self.navigationController pushViewController:secVCInstance]; 
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across an interesting problem today. I have a text email I'm sending
So I came across an interesting problem today. We have a WCF web service
I have came across very interesting problem which I think it's on Salesforce's end
I came across an interesting problem recently. In an ASP.NET Master Page, I have
I have came across a very interesting problem. I have a UILabel and a
I just came across the interesting problem of trying to trim the leading zeroes
While doing some casual reading I came across an interesting quote by Scott Meyers
I came across an interesting problem today whilst implementing a feature into a dynamic
I just came across an interesting situation in JavaScript. I have a class with
I'm using CodeIgniter and I came across an interesting problem. I need to use

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.