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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:52:48+00:00 2026-06-01T16:52:48+00:00

In my application window I have two NSViews. On the left the NSView (Menu)

  • 0

In my application window I have two NSViews. On the left the NSView (“Menu”) contains a few buttons. When one of the buttons is clicked it should change the contents of the right NSView (“Content”).

For each of the views on the right I have a separate NSViewControllers that get loaded and their views gets added as a subview. When a further button gets pressed on the left the added subviews on the right should be removed and the new view should be loaded as a subview.

To accomplish this I load my Menu in AppDelegate with the following:

 MenuVC *menuSubView = [[MenuVC alloc] initWithNibName:@"MenuVC" bundle: nil];
    menuSubView.contentView = (NSView*)[self contentView];
    [[self menuView] addSubview:[menuSubView view]];

This works fine. As you can see I have a NSView pointer in the Menu VC which points to the contentView so that I can populate it with the subviews.

Now as a method for one of the button presses I do the following:

SomeContentVC *subView = [[SomeContentVC alloc] initWithNibName:@"SomeContentVC" bundle:nil];
    [self.contentView addSubview:[subView view]];

This does not work.

If I however add a subview from the awakeFromNib method of the MenuViewController implementation (in the case of default content when the app opens) it works. However when I try to remove that subview using

[[self.contentView setSubviews:[NSArray array]];

I can’t. Interesting is also that if I try to count the number of subviews (even after having added one in the awakeFromNib method) it returns 0 subviews for self.contentView. Why? How can I get it to work properly?

Thanks

  • 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-01T16:52:50+00:00Added an answer on June 1, 2026 at 4:52 pm

    The fact that messaging self.contentView achieves nothing except, for some things, returning 0 probably means that self.contentView is nil.

    Do you perhaps have two instances of MenuVC by accident? Perhaps one instantiated in a NIB and one instantiated in code?

    When in doubt, log everything. Log self in various methods. Log menuSubView just after you create it. Log menuSubView.contentView just after you assign it. Etc. Eventually, you’ll probably see that you’re interacting with different objects than you thought you were.

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

Sidebar

Related Questions

I have two windows application, one is a windows service which create EventWaitHandle and
I have two window form applications written in C, one holds a struct consisting
I have created two forms in my Windows Application. One Form acts as a
I have window application and on that there is one webbrowser control and I
Problem is like this: I have two winapi application's. There is only one way
I'm creating Win32 application and I have two projects. The first one is a
On my Java Swing application I have two components. On the left side is
I have two code files, one contains my WinMain() function, and all functions related
I am working on Windows client application using c#, have two projects in my
Scenario I have a windows forms application. I want to use two different WCF

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.