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

The Archive Base Latest Questions

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

I created a new Xcode project with a view-based app template. In the .m

  • 0

I created a new Xcode project with a view-based app template. In the .m of the view controller I overwrote this:

// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization

        NSLog(@"initWithNibName...");
    }
    return self;
}


- (id)init {
    NSLog(@"initWithNibName...");
    return [super init];
}

However, I never get that NSLog. That’s also my experience from other projects. This method is never called. Not even -init from NSObject.

The View Controller is created inside the XIB file. How’s that possible, that the Nib Loading System instantiates this class without any kind of initialization?

Why? And what’s the alternative instead of -loadView and -viewDidLoad?

Another great reason to stay far away from XIB files?

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

    From the iOS Resource Programming Guide

    In iPhone OS, any object that conforms to the NSCoding protocol is initialized using the initWithCoder: method. This includes all subclasses of UIView and UIViewController whether they are part of the default Interface Builder library or custom classes you define.

    Think of it this way: the designated initializer is called when your view controller is first created in Interface Builder. Then, when you save the nib file, the view controller instance is stored in the file. Later, when the nib is loaded, the instance is recreated from the nib.

    Since it’s being recreated rather than created for the first time, a different initialization method is used. This method (-initWithCoder:) restores the object’s state using values from the nib file, which can include settings for properties beyond those that were set by the designated initializer. This mechanism relies on the NSCoding protocol, which allows it to work generically for many different classes.

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

Sidebar

Related Questions

Just created a new project in Xcode (View based), and tried creating a button
This is happening on Vista. I created a new dialog based MFC project to
I've created a new View-based Application in XCode. In the ViewController, the only code
I have noticed that when you create a new xcode project as a view
I created a new SplitView iPad project in Xcode and setup the code to
How would I change the initial templates created by Xcode when creating a new
I've created a new C++ project in Visual Studio 2008. No code has been
We have created a new List View Style that shows thumbnails from a picture
I am new to Windows Mobile and created an app that needs to do
I created a new SharePoint portal for testing purposes using a manually added HOSTS

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.