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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:07:56+00:00 2026-06-14T11:07:56+00:00

In the didFinishLaunchingWithOptions method in the App Delegate, a string, myString is initialised with

  • 0

In the didFinishLaunchingWithOptions method in the App Delegate, a string, myString is initialised with a string retrieved from NSUserDefaults (confirmed with an NSLog). I have multiple view controllers in this tab-based project, and all of them are accessing the app delegate variables just fine, apart from one. The only difference between this view controller and the others is that it is a UIViewController as opposed to a UITableViewController (though the latter inherited).

In the UIViewController‘s initialisation I’ve put:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        if (self.appDelegate.myString == nil)
            NSLog(@"nil");
        }
    return self;
}

The strange part: in the initWithNibName method, myString (and all other variables in the app delegate) is nil. However when I fire this in the viewDidAppear method, it isn’t nil (and I get the correct string). Furthermore it returns nil in the viewDidLoad method too. So I tried initialising self.appDelegate in viewDidLoad and then checking the string but it still returns nil.

I’ve gone wrong somewhere but can’t figure it out.

  • 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-14T11:07:57+00:00Added an answer on June 14, 2026 at 11:07 am

    Just an oversight. I initialised the view controller before retrieving the variable from NSUserDefaults.

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

Sidebar

Related Questions

I'm trying to call a method in the view controller from the app delegate,
I am wondering if an iOS app delegate's application:didFinishLaunchingWithOptions: method executes from within the
I'm having some problems in passing context from the app delegate to the view
I'm programmatically creating a tab bar based app. In the application:didFinishLaunchingWithOptions (app delegate) method
I need to make multiple asynchronous service calls in the application:didFinishLaunchingWithOptions: method from my
My appDelegate, in the method didFinishLaunchingWithOptions I load my view controller then create a
I am using multiple controller during launch of an application in app delegate. One
I have a question about the memory management. In my app delegate, I have
I have an app based on the Utility template (i.e. Main and Flip view
I need to show another view from rootviewcontroller on button click. I have written

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.