problem loading a window in a new NIB using NSWindowController.

  • Hi

    I am trying to load a Nib File Using the code below.  [myWindowController window] crashes the app.

      NSWindowController *myWindowController = [[[MyWindowController alloc] initWithWindowNibName:@"SymbolsView"] autorelease];

      [[myWindowController window] makeKeyAndOrderFront:nil];

    SymbolsView is the Nib name in which I have one window which has a tableView. I have made MyWindowController (NSWindowController) which is the file's owner of the NIB, as the delegate for the window and have connected  my window to the 'window' outlet in MyWindowController.

    Am I missing something here?

    Thank you
    DG

          Flying to Bangalore or Bhopal? Search for tickets at http://in.farechase.yahoo.com
  • On 3 Oct 2007, at 1:40 PM, deepak gopal wrote:

    > I am trying to load a Nib File Using the code below.
    > [myWindowController window] crashes the app.

    "Crashes the app" isn't very informative. Does the application crash
    at the very spot of the call? At some point deeper in the call chain
    from [myWindowController window]? Later? What is the stack trace at
    the point of the crash?

    > NSWindowController *myWindowController = [[[MyWindowController
    > alloc] initWithWindowNibName:@"SymbolsView"] autorelease];

    Why are you autoreleasing your window controller? Don't you want it to
    exist after the next pass through the run loop?

    > [[myWindowController window] makeKeyAndOrderFront:nil];

    When do you execute this line? In the same function as the alloc/
    autorelease? Or later, after myWindowController has been released out
    from under you?

    — F
  • Answers below.

    ----- Original Message ----
    From: Fritz Anderson <fritza...>
    To: deepak gopal <deepak_gopal_21...>
    Cc: cocoa dev <cocoa-dev...>
    Sent: Wednesday, 3 October, 2007 12:04:10 PM
    Subject: Re: problem loading a window in a new NIB using NSWindowController.

    On 3 Oct 2007, at 1:40 PM, deepak gopal wrote:

    > I am trying to load a Nib File Using the code below.
    > [myWindowController window] crashes the app.

    "Crashes the app" isn't very informative. Does the application crash
    at the very spot of the call? At some point deeper in the call chain
    from [myWindowController window]? Later? What is the stack trace at
    the point of the crash?

    The application crashes at the very spot I call [myWindowController window]

    > NSWindowController *myWindowController = [[[MyWindowController
    > alloc] initWithWindowNibName:@"SymbolsView"] autorelease];

    Why are you autoreleasing your window controller? Don't you want it to
    exist after the next pass through the run loop?

    No I won't need it for the next pass, this doesn't affect the next statement, does it?

    > [[myWindowController window] makeKeyAndOrderFront:nil];

    When do you execute this line? In the same function as the alloc/
    autorelease? Or later, after myWindowController has been released out
    from under you?

    I execute it in the same function.

        — F

          Save all your chat conversations. Find them online at http://in.messenger.yahoo.com/webmessengerpromo.php
  • It seems likely that (at least) one of three things is happening.
    Either your myWindowController is invalid, your [myWindowController
    window] is invalid, or something is failing during the initialization
    or waking of your controller nib.

    Have you checked the values of myWindowController and
    [myWindowController window] to see if they look valid?

    You mentioned there's a table in the window-- are there any other
    instantiated objects in the nib that might be failing/crashing?

    What does the crash log say?

    It's unclear from your message below if MyWindowController is an
    NSWindowController subclass. If so, have you stepped through the
    init, awakeFromNib and windowControllerDidLoadNib methods looking for
    problems?

    At what point (in which method of which class) are you executing the
    code below?

    You haven't provided enough information to debug this. If you go
    through those first steps above, they will probably yield the answer.
    If not, post the results.

    - d

    On Oct 3, 2007, at 2:40 PM, deepak gopal wrote:

    > Hi
    >
    > I am trying to load a Nib File Using the code below.
    > [myWindowController window] crashes the app.
    >
    > NSWindowController *myWindowController = [[[MyWindowController
    > alloc] initWithWindowNibName:@"SymbolsView"] autorelease];
    >
    >
    >
    > [[myWindowController window] makeKeyAndOrderFront:nil];
    >
    > SymbolsView is the Nib name in which I have one window which has a
    > tableView. I have made MyWindowController (NSWindowController)
    > which is the file's owner of the NIB, as the delegate for the
    > window and have connected  my window to the 'window' outlet in
    > MyWindowController.
    >
    > Am I missing something here?
    >
    > Thank you
    > DG
  • I am sorry this was in the draft and I didn't realize that I hadn't sent it. :(
    I found out that it was a problem with the nib I had created.
    My app is loading the window now.
    --------------------------------------
    My application stops as soon as my control reaches [myWindowController window].
    myWindowController when printed gives " <MyWindowController: 0x3c0f10>", so I guess this is good.

    This is my method.
    - (IBAction)downloadSymbols:(id)sender {

      NSWindowController *myWindowController = [[[MyWindowController alloc]
        initWithWindowNibName:@"SymbolsView"] autorelease];

      NSLog (@"myWindowController %@", myWindowController );

      [[myWindowController window] makeKeyAndOrderFront:self];

    }

    In SymbolsView.nib,  I have a Window (which contains a NSTableView) and a object of class "LoadFunction" which would act as the dataSource for the TableView in the window.
    I have made MyWindowController class which is a subclass of NSWindowController as the File's Owner.
    The outlet "window" of File's Owner is connected to the Window and the File's Owner is made the "delegate" of the Window.

    In the MainMenu.nib I have a window with a button "Grant" which is connected to the Action Class above {- (IBAction)downloadSymbols:(id)sender }.

    So when I click on the button "Grant" I expect the Window to popup.

    This doesn't happen.

    DG

    ----- Original Message ----
    From: Dave Hersey <davelists...>
    To: Cocoa Dev <cocoa-dev...>
    Sent: Wednesday, 3 October, 2007 5:02:52 PM
    Subject: Re: problem loading a window in a new NIB using NSWindowController.

    It seems likely that (at least) one of three things is happening.
    Either your myWindowController is invalid, your [myWindowController
    window] is invalid, or something is failing during the initialization
    or waking of your controller nib.

    Have you checked the values of myWindowController and
    [myWindowController window] to see if they look valid?

    You mentioned there's a table in the window-- are there any other
    instantiated objects in the nib that might be failing/crashing?

    What does the crash log say?

    It's unclear from your message below if MyWindowController is an
    NSWindowController subclass. If so, have you stepped through the
    init, awakeFromNib and windowControllerDidLoadNib methods looking for
    problems?

    At what point (in which method of which class) are you executing the
    code below?

    You haven't provided enough information to debug this. If you go
    through those first steps above, they will probably yield the answer.
    If not, post the results.

    - d

    On Oct 3, 2007, at 2:40 PM, deepak gopal wrote:

    > Hi
    >
    > I am trying to load a Nib File Using the code below.
    > [myWindowController window] crashes the app.
    >
    > NSWindowController *myWindowController = [[[MyWindowController
    > alloc] initWithWindowNibName:@"SymbolsView"] autorelease];
    >
    >
    >
    > [[myWindowController window] makeKeyAndOrderFront:nil];
    >
    > SymbolsView is the Nib name in which I have one window which has a
    > tableView. I have made MyWindowController (NSWindowController)
    > which is the file's owner of the NIB, as the delegate for the
    > window and have connected  my window to the 'window' outlet in
    > MyWindowController.
    >
    > Am I missing something here?
    >
    > Thank you
    > DG


          Chat on a cool, new interface. No download required. Go to http://in.messenger.yahoo.com/webmessengerpromo.php
  • dg -

    Is the window outlet valid when you call [myWindowController window]?

    Is the app actually crashing? Do you see exceptions firing in the
    Debug Console by any chance?

    I kind of suspect that the problem is with your table and datasource,
    but that's a bit of a wild guess. Have you tried deleting the table
    to see if the window appears if it's not being set up?

    - d

    On Oct 5, 2007, at 9:12 PM, deepak gopal wrote:

    > I am sorry this was in the draft and I didn't realize that I hadn't
    > sent it. :(
    > I found out that it was a problem with the nib I had created.
    > My app is loading the window now.
    > --------------------------------------
    > My application stops as soon as my control reaches
    > [myWindowController window].
    > myWindowController when printed gives " <MyWindowController:
    > 0x3c0f10>", so I guess this is good.
    >
    > This is my method.
    > - (IBAction)downloadSymbols:(id)sender {
    >
    > NSWindowController *myWindowController = [[[MyWindowController
    > alloc]
    > initWithWindowNibName:@"SymbolsView"] autorelease];
    >
    > NSLog (@"myWindowController %@", myWindowController );
    >
    > [[myWindowController window] makeKeyAndOrderFront:self];
    >
    > }
    >
    > In SymbolsView.nib,  I have a Window (which contains a NSTableView)
    > and a object of class "LoadFunction" which would act as the
    > dataSource for the TableView in the window.
    > I have made MyWindowController class which is a subclass of
    > NSWindowController as the File's Owner.
    > The outlet "window" of File's Owner is connected to the Window and
    > the File's Owner is made the "delegate" of the Window.
    >
    > In the MainMenu.nib I have a window with a button "Grant" which is
    > connected to the Action Class above {- (IBAction)downloadSymbols:
    > (id)sender }.
    >
    > So when I click on the button "Grant" I expect the Window to popup.
    >
    > This doesn't happen.
    >
    > DG
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today