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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:43:58+00:00 2026-05-31T03:43:58+00:00

I have a navigation controller residing inside a tab bar controller and whenever I

  • 0

I have a navigation controller residing inside a tab bar controller and whenever I try to access a class from a class within the navigation controller all my values return (null).

This is how I’m trying to do it.

AppDelegate.h

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> {
NSString *searchQueryA;
}

@property (strong, nonatomic) NSString *searchQueryA;

ThirdViewController.h

#import "MasterViewController.h"
#import "AppDelegate.h"

@class MasterViewController;

@interface ThirdViewController : UIViewController {
code
}

@property (strong, retain) MasterViewController *masterViewController;

ThirdViewController.m

- (IBAction)showDetail:(id)sender {
AppDelegate *appDelegate = [[AppDelegate alloc] init];
appDelegate.searchQueryA = _searchField.text;
masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
[self.navigationController pushViewController:masterViewController animated:YES];
}

MasterViewController.h

#import "AppDelegate.h"
@interface MasterViewController : UITableViewController
{
NSString *searchQueryM;
}

@property (nonatomic, strong) NSString *searchQueryM;

MasterViewController.m

 AppDelegate *appDelegate = [[AppDelegate alloc] init];
 searchQueryM = appDelegate.searchQueryA;

 NSLog(@"%@", searchQueryM);

And in the log I can see that searchQueryM is (null). If I try to access the variable in AppDelegate from another class, that isn’t involved with navigation controller, then it shows perfectly fine. What am I missing?

If you need to see more code I’d be happy to provide it.

EDIT:

For legibility I’ll post code changes here:

I have the delegate in my AppDelegate.h

As Leonardo pointed out I only alloc’d and init’d my AppDelegate. I changed that snippet to this:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
searchQueryM = appDelegate.searchQueryA; 

but still no go as searchQueryM still is (null).

This is what I do with searchQueryM

MasterViewController.h

@interface MasterViewController : UITableViewController
{
NSString *searchQueryM;
}

@property (nonatomic, strong) NSString *searchQueryM;

MasterViewController.m

@synthesize searchQueryM;

I’m fairly new to Objective-C (as well as OO-programming) and should probably read a book on it, but it seems to me like there isn’t a lot more to it than that. Do correct me if I’m wrong.

EDIT 2

ThirdViewController.h

@interface ThirdViewController : UIViewController {
UITextField *_searchField;
}

@property (nonatomic, strong) IBOutlet UITextField *searchField;

ThirdViewController.m

 @synthesize searchField = _searchField;

 ...

 - (IBAction)showDetail:(id)sender {
 _code_
 NSLog(@"%@", searchField.text);
 _code_

If i type in “asd” in the searchField textfield and output it with the log I get “asd”.
}

  • 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-31T03:43:59+00:00Added an answer on May 31, 2026 at 3:43 am

    Why are you alloc init your AppDelegate ?
    The AppDelegate should be accessed with:

    [[UIApplication sharedApplication] delegate]
    

    We should see how you normally initialize searchQueryM, you are getting null, probably because the AppDelegate get only allocated and init, but the logic that initialize its properties never gets called.

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

Sidebar

Related Questions

I have a tab-bar and navigation controller application (like Youtube app or Contacts app).
Description I have a Tab Bar Controller with a navigation controller tab. The first
I have 2 tab bar items. The first tab have a navigation controller(3 views)
I want to have a navigation controller enrollment flow before my actual tab bar
i have just converted an app i was making from a navigation controller app
I have a navigation controller and when I place an image for navigation bar
HI Everyone, I have a navigation bar with a navigation controller. In one of
I have application with 2 tab bars. In second tab bar I have navigation
I have a navigation controller app. I created a RootViewController class with Xib file.
I have a naviation controller. I create a tab bar controller and add 3

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.