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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:54:19+00:00 2026-06-09T08:54:19+00:00

i have a subclass of NSViewController that loads its view from a nib (with

  • 0

i have a subclass of NSViewController that loads its view from a nib (with initWithNibName:bundle: and it is the file’s owner of that nib).

I need to do some initialization after the nib is loaded and i want my code to be the most compatible :

  • In ios : There is the viewDidLoad method to do that
  • In osx : In snow leopard, there is no method like viewDidLoad but awakeFromNib is called on the file’s owner of the nib too

So my questions are :

  1. Is awakeFromNib called also on the file’s owner of the nib in Lion ?
  2. If i use awakeFromNib, do i need to call [super awakeFromNib] ? (is NSViewController implements awakeFromNib ?)
  3. If answer 1 is YES, is this a good solution ? :
- (void)initAfterNibLoaded {
   ...
}

- (void)viewDidLoad {
   // Code for ios
   [self initAfterNibLoaded];
}

- (void)awakeFromNib {
   // Code for osx

   // Not sure if necessary
   [super awakeFromNib];

   [self initAfterNibLoaded];
}

If answer 1 is NO, is this a good solution ? :

- (void)viewDidLoad {
   // Initialize after nib loaded
}

#ifndef TARGET_OS_IPHONE
- (void)loadView {
   // Call parent method
   [super loadView];

   // Simulate viewDidLoad method
   [self viewDidLoad];
}
#endif

Thank you

  • 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-09T08:54:22+00:00Added an answer on June 9, 2026 at 8:54 am

    Here is what I found:

    1. Yes, awakeFromNib: is called also on the file’s owner of the nib in Lion (and normally it’s the same for the new Mountain Lion).

    2. Starting on OSX 10.6, there is a category on NSObject that adds awakeFromNib, so it’s safe to call [super awakeFromNib] from any subclass. For OSX before 10.6, we can use instancesRespondToSelector: to know if the parent class implements awakeFromNib, the NSView or NSObject subclass must not call [super awakeFromNib].

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

Sidebar

Related Questions

I have a subclass of NSWindowController that has its own nib and another class
I have a subclass of UIView that's instantiated in a XIB file. I need
I have a subclass of UIScrollView that I have set as the view of
I have a subclass of UIImageView that I need to know when is touched.
I have a subclass that calls a method from a superclass. The method in
I have a subclass of UIView that displays some Core Graphics drawn in a
I have a subclass from control and I want set text for that. When
I have a subclass that has an extra method from the superclass so when
I have a TextViewController which is a subclass of NSViewController which controls a View
I have subclass that inherits from a dict. On __getitem__ method I'd like to

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.