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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:17:36+00:00 2026-05-25T21:17:36+00:00

I have a very newbie question about IOS apps… If I create a new

  • 0

I have a very newbie question about IOS apps… If I create a new View Based Application called TestForStackOverflow, Xcode automatically creates code like this for the TestForStackOverflowAppDelegate.h:

@class TestForStackOverflowViewController;

@interface TestForStackOverflowAppDelegate : NSObject <UIApplicationDelegate>

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet TestForStackOverflowViewController *viewController;

@end

and the following in TestForStackOverflowAppDelegate.m:

#import "TestForStackOverflowAppDelegate.h"

#import "TestForStackOverflowViewController.h"

@implementation TestForStackOverflowAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

[...]

Here come my questions:

1) where is the TestForStackOverflowAppDelegate class set as delegate for the current application? Is it done “automagically”? I’ve seen that the main.m source file contains only
the following code:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

Shouldn’t it set the application delegate class in the fourth parameter of the UIApplicationMain function invocation?

2) where are the window and viewController properties of TestForStackOverflowAppDelegate class being set?

3) this may be trivial, but why do we have synthesize window = _window, without having an instance variable called _window in TestForStackOverflowAppDelegate interface? I’ve seen that you can declare @properties without having the corresponding iVars in the class interfaces (maybe they are automatically created by the compiler), but is it a good practice or should you always create the corresponding iVars in your classes?

Excuse me for the very long message, I just hope I’ve not written a too obvious question since here in Italy is late night and I’m very tired.. but when these questions come into my head, I can’t wait for the solution 🙂

  • 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-25T21:17:36+00:00Added an answer on May 25, 2026 at 9:17 pm

    How is the app delegate class loaded?

    In your -info.plist file there is a key named “Main nib file base name” and has a view something like MainWindow.xib. In that xib file, there’s a file’s owner proxy object and it has a delegate set to the app delegate class.

    Open that XIB in the designer. Notice the File’s Owner object at the top, context click on it and look at the delegate object. Now look at the objects in the design below the (XCode 4) line – you should see the app delegate object there.

    Where is the window and viewController for the appDelegate set?

    Look in the designer and context click on the app delegate object below the (XCode 4) line. The window and viewController target is tied there.

    _window iVar

    It’s automatically provided for you. Not clear to me whether it’s inherited or generated by the compiler.

    Here’s more on _ iVars:
    Why rename synthesized properties in iOS with leading underscores?

    If you chose to do the equivalent in code:

    remove plist xib reference
    main.m: pass name of delegate

    int main(int argc, char *argv[])
    {
        int retVal = UIApplicationMain(argc, argv, nil, @"HelloViewAppDelegate");
    

    In app delegate:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
        CGRect windowBounds = screenBounds;
        windowBounds.origin.y = 0.0;
    
        // init window
        [self setWindow: [[UIWindow alloc] initWithFrame:screenBounds]];
    
        // init view controller
        _mainViewController = [[MainViewController alloc] init];
    
        [[self window] addSubview:[_mainViewController view]];
    
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me, i'm very newbie i have question about datatables (jquery plug in)
Sorry this is a very newbie question. We have this massive application I am
I'm very new to F# so please excuse the completely newbie question: I have
I'm a newbie and I have a very basic question about PHP arrays Code:
quick and very basic newbie question. If i have list of dictionaries looking like
And again a newbie question. ;-) I am setting my View Model based on
Very primitive question but I am stuck (I guess being newbie). I have a
This is a very newbie question, and this is something I have done many
This is a very newbie question, but something completely new to me. In my
This must be a very stupid newbie question, but I have spent my whole

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.