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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:21:39+00:00 2026-06-01T23:21:39+00:00

I have one class called MainMenu, which has a method called switchViews, with 2

  • 0

I have one class called MainMenu, which has a method called switchViews, with 2 parameters, an NSWindow and an NSView.

I then have the AppDelegate, which i want to use this method in the ‘applicationDidFinishLaunching’.

So in the AppDelegate.h i have imported the MainMenu.h and in the AppDelegate.m I use as follows:

MainMenu *theMainMenu = [[MainMenu alloc]] init];
[theMainMenu switchViews:param1:param2;

There are no warnings or errors, it just doesn’t call the method.

If i copy and paste the method instead of calling it, it works fine so it’s not a problem with the variables, it seems there is just an error running the method if it’s in a different class?

Any help would be greatly appreciated.

Thanks in advance

switchViews method:

- (void)switchViews:(NSWindow*)mainWindow:(NSView*)newView {
    NSView *dummyView;
    [theMainWindow setContentView:dummyView];
    [theMainWindow setContentSize:newView.frame.size];
    [theMainWindow setContentView:newView];
}

EDIT: sorry guys, it was just a typo.

SOLUTION: I was using the wrong parameter in the method call. Below is the working code:

- (void)switchViews:(NSWindow*)mainWindow:(NSView*)newView {
    NSView *dummyView;
    [mainWindow setContentView:dummyView];
    [mainWindow setContentSize:newView.frame.size];
    [mainWindow setContentView:newView];
}
  • 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-01T23:21:40+00:00Added an answer on June 1, 2026 at 11:21 pm
    MainMenu *theMainMenu = [MainMenu alloc[ init]];
    

    If that’s your code, then it isn’t even running, because the build fails, because that code is invalid.

    Assuming your actual code doesn’t contain syntax errors, nothing happening generally means you sent a message to nil. Either -[MainMenu init] returned nil, or the implementation of switchViews:: tried to send a message to an object it doesn’t have.

    Assuming you don’t have any statements in -[MainMenu init] to return nil, the latter case is more probable. Make sure that it creates whatever objects it needs to, or, if you mean for it to be nib-based, make sure that you have hooked up all of your MainMenu object’s outlets and that you didn’t forget to load the nib.

    Edit:

    - (void)switchViews:(NSWindow*)mainWindow:(NSView*)newView {
        NSView *dummyView;
        [theMainWindow setContentView:dummyView];
        [theMainWindow setContentSize:newView.frame.size];
        [theMainWindow setContentView:newView];
    }
    

    You named the method’s first argument variable mainWindow, but then you send messages to theMainWindow.

    If the MainMenu object has an outlet named theMainWindow, make sure that that’s hooked up, and remove the redundant first argument. Alternatively, kill off the outlet (or whatever theMainWindow is) and use mainWindow.

    Also, since the AppDelegate (for some reason) is passing the window to the MainMenu object, make sure the AppDelegate actually has the window. Start by checking the value of “param1” in the AppDelegate code.

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

Sidebar

Related Questions

I have one class, called A, and it has it's own header file. Then
I have three files: one called sql.php witch has a class db that I
I have a class User with one field called birthDate which is a java.sql.Date
I have one Class with 2 methods. The first method is called by the
I have one class called dog and another class called cat. Dog has an
I have one class called HyperlinkEventMonitor that implements a HyperlinkListener. I want to extend
I have a model called Contact which has_one guest like so. class Contact <
I have one abstract class -let's say myBase. And I want all the classes
I have one parent class, which is abstract class for now, for four different
I have one class called Person that basically looks like: public class Person {

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.