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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:44:01+00:00 2026-06-16T17:44:01+00:00

I am very new to iPhone app development. I am developing one example application

  • 0

I am very new to iPhone app development.
I am developing one example application for iPhone emulator using Objective-C++ and std CPP.

I have two views in my application, on some events from CPP code i am displaying second view using following code from the first view controller.

// Defined in .h file 
secondViewScreenController *mSecondViewScreen;

// .mm file Code gets called based on event from CPP (common interface function between Objective-C++ and CPP code)
mSecondViewScreen = [[secondViewScreenController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:mSecondViewScreen animated:YES];

I am able to see second view coming on screen, but problem is that i am unable to end/remove second view controller from first view controller.

How can i remove second view controller from first view controller using second view controller’s pointer or using any other method.

To remove second view i have following code in second view controller file, which gets called on button click event of second view.

// In .mm of second view controller. 
- (IBAction)onEndBtnClicked:(UIButton *)sender
{
   [self dismissModalViewControllerAnimated:NO];
   [self.navigationController popViewControllerAnimated:YES];
}

Above code works perfectly, when i click on the seconds view’s end button it removes the second view controller from the screen and navigets to first view, how can i use same code to remove second view from the first view controller.

I tied to use NSNotificationCenter to send event from first view to second view to call the function onEndBtnClicked but it is not working.

What is the proper way of doing it?

OSX version: 10.5.8 and Xcode version: 3.1.3

  • 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-16T17:44:02+00:00Added an answer on June 16, 2026 at 5:44 pm

    In the secondViewController create a protocol like:

    @protocol SecondViewScreenControllerDelegate <NSObject>
    
    - (void)secondViewScreenControllerDidPressCancelButton:(UIViewController *)viewController sender:(id)sender;
    
    // Any other button possibilities
    
    @end
    

    Now you have to add a property in the secondViewController class:

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

    You sinthesize it in the secondViewController implementation:

    @synthesize delegate = _delegate;
    

    Finally all you have to do is implement the protocol in your firstViewController and set the secondViewController properly prior presenting it:

    @interface firstViewController : UIViewController <SecondViewScreenControllerDelegate>
    

    …

    @implementation firstViewController
    
        - (void)secondViewScreenControllerDidPressCancelButton:(UIViewController *)viewController sender:(id)sender
        {
             // Do something with the sender if needed
             [viewController dismissViewControllerAnimated:YES completion:NULL];
        }
    

    Then when presenting the secondViewController from the first:

    UIViewController *sec = [[SecondViewController alloc] init]; // If you don't need any nib don't call the method, use init instead
    sec.delegate = self;
    [self presentViewController:sec animated:YES completion:NULL];
    

    And ready. Whenever you want to dismiss the secondViewController from the first, just call: (inside the secondViewController implementation)

    [self.delegate secondViewScreenControllerDidPressCancelButton:self sender:nil]; // Use nil or any other object to send as a sender
    

    All that happens is that you send a pointer of the secondViewController that you can use from the first. Then you can work with it without problem. No C++ needed. In Cocoa you won’t need C++. Almost everything can be done with Objective-C, and it’s more dynamic.

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

Sidebar

Related Questions

Very new to iPhone app development. I am developing one example application for iPhone
I am very new to iPhone development. I downloaded the iPhoneHTTPServer application from bellow
I am very new to iPhone. I have developed two version of an application
Am very new to iPhone application development. Am adding the events to iCal from
I'm very new to iPhone development. I want to create a utility application much
I am very new to iOS development. I am developing an app, currently i
I am very new to iPhone development. In my app, I want to send
Im very new to game development on the iPhone... And I have a question:
I am new to Objective-C and iPhone development in general. I am using the
I'm very new to Objective-C and I'm trying to develop an iPhone app. My

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.