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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:20:36+00:00 2026-05-16T11:20:36+00:00

I know this question as been asked over and over but it’s still quite

  • 0

I know this question as been asked over and over but it’s still quite obscure to me, so I guess making an example with my code instead will probably be easier .

I know that you can use :

  • A global variable, ( not good practice ).
  • Use a delegate
  • Use a singleton

Say I’ve got this piece of code here in my first view controller header :

#import <UIKit/UIKit.h>


@interface FirstViewController : UIViewController {

    IBOutlet UITextField *Te;
NSInteger evTe;
}


@property (nonatomic, retain) UITextField *Te;
@property (nonatomic) NSInteger evTe;


- (IBAction) makeKeyboardGoAway;

@end

and then this in my implementation file

#import "FirstViewController.h"


@implementation FirstViewController

@synthesize Te;

- (IBAction) makeKeyboardGoAway;
{
    [Te resignFirstResponder];  
    evTe = [Te.text intValue];
}

How would I call evTe in my SecondViewController ? ( maybe using a delegate ?) .

This is what I’ve got in the second view Controller, header :

@interface SecondViewController : UIViewController {


        NSInteger evTe;

}



@property (nonatomic) NSInteger evTe;

and implementation :

- (IBAction) makeKeyboardGoAway;
{



    FirstViewController *first = [[FirstViewController alloc] init];
    first.evTe = self.evTe;

    NSLog(@"second value is %i",evTe);

}

Thanks a lot !


Edit for Tob

FirstViewController.m

- (IBAction) makeKeyboardGoAway;
{
    evTe = [Te.text intValue];
    NSLog(@"The value of integer num is %i", evTe);

    NSDictionary *changedValues = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:evTe] forKey:@"evTe"];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"evTeChanged" object:self userInfo:changedValues];


}

SecondViewController.m

 - (void)viewDidLoad {
     [super viewDidLoad];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodToCall:) name:@"evTeChanged" object:nil];

 }

- (void)methodToCall:(NSNotification *)aNotification{

    NSDictionary *changedValues = [[aNotification userInfo]  objectForKey:@"evTe"];               
    NSString *dictionaryString = [changedValues description];
    NSLog(@"Notification returning %d",dictionaryString);

}

Unfortunately I’m not getting any log from the SecondView ..

  • 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-16T11:20:37+00:00Added an answer on May 16, 2026 at 11:20 am

    By creating a @property called evTe or whatever in both view controllers.

    If the FirstViewController is responsible for creating the SecondViewController you could store the value of evTe in a property in FirstViewController and then after you have created the SecondViewController you set the evTe property there as well.

    - (IBAction) makeKeyboardGoAway;
    {
        [Te resignFirstResponder];  
        self.evTe = [Te.text integerValue];
    }
    

    // other method where SecondViewController is created

    SecondViewController* second = [[SecondViewController alloc] init];
    second.evTe = self.evTe;
    // do what ever
    

    –Edit–

    @interface FirstViewController : UIViewController {
    
        IBOutlet UITextField *Te;
        NSInteger evTe;
    
    }
    
    @property (nonatomic, retain) UITextField *Te;
    @property (nonatomic) NSInteger evTe;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked over and over again but still
I know this question has been asked a zillion times, but I still feel
I know this question has been asked several times, but I can't quite seem
I know this question has been asked few times over SO but none of
I know this question has been asked many times over, but I am currently
I know this question has been asked over and over, but I can't seem
I know that this question has been asked over and over again, but nothing
I know this question as been asked countless times, but believe me I've searched
I know this question had been asked a hundred times, but I have difficulties
I know this question has been asked before, but non of the solutions solve

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.