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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:13:07+00:00 2026-06-06T22:13:07+00:00

In a view, let’s call it firstView I created a secondView as follows and

  • 0

In a view, let’s call it firstView I created a secondView as follows and pushed it if certain thing happened in the firstView:

SecondViewController *secondVC = [[secondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];


    [self.navigationController pushViewController:secondVC animated:YES];
    [secondVC release];

Now when I’m in the secondView if let say a button is pressed I want to go back to firstView and also pass back a value from secondView to the firstView (let say an integer value of a textfield from secondView to the firstView).

Here is what I tried:

@protocol SecondViewControllerDelegate;

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

@interface SecondViewController : UIViewController <UITextFieldDelegate>
{
    UITextField *xInput;
    id <SecondViewControllerDelegate> delegate;
}

- (IBAction)useXPressed:(UIButton *)sender;

@property (assign) id <SecondViewControllerDelegate> delegate;

@property (retain) IBOutlet UITextField *xInput;

@end

@protocol SecondViewControllerDelegate
- (void)secondViewController:(SecondViewController *)sender xValue:(int)value;

@end

And in the m file

- (IBAction)useXPressed:(UIButton *)sender
{
    [self.delegate secondViewController:self xValue:1234]; // 1234 is just for test
}

And then in the firstView I did:

#import "SecondViewController.h"

@interface FirstViewController : UITableViewController <SecondViewControllerDelegate> {

}

@end

And implemented:

- (void) secondViewController:(SecondViewController *)sender xValue:(int)value
{
    [self.navigationController popViewControllerAnimated:YES];
}

Now, the problem is for one in FirstViewController I get the warning that “No definition of protocol “SecondViewControllerDelegate” is found, and for two the delegate method (last piece of code above) does not get invoked at all. Can somebody please tell me what’s wrong?

  • 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-06T22:13:08+00:00Added an answer on June 6, 2026 at 10:13 pm

    After this line

    SecondViewController *secondVC = [[secondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    

    Add

    secondVC.delegate = self;
    

    Also instead of

    - (void) secondViewController:(SecondViewController *)sender xValue:(int)value
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    

    You should use

    - (void) secondViewController:(SecondViewController *)sender xValue:(int)value
    {
        [sender popViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom View (let's call it MyView ) which basically just
In my project, there are two view controllers - let's say firstViewController and secondViewController.
I have a view let's call it 'NestedView', which defines nested region, due to
When I transition from one view controller (let's call it MasterViewController ) to another
I'm trying to add a custom root view controller (let's call it MyViewController )
In my AppDelegate, I'm instantiating a UINavigationController and adding my main view (let's call
I have two view controllers let's call them A and B (1) in A
I have a view controller let's call it View Controller A. I have a
So let's say I have a view that access a date: <%= Html.TextBoxFor(model =>
Let's say I have some classes like this: abstract class View(val writer: XMLStreamWriter) {

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.