• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with an NSWindowController's retain count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with an NSWindowController's retain count


  • Subject: Problem with an NSWindowController's retain count
  • From: Ben Kazez <email@hidden>
  • Date: Tue, 19 Jul 2005 15:23:29 -0400

My app delegate has an IBAction for creating and displaying an
instance of the main viewer window. The problem is that the window
shows up for a very brief time and then disappears, unless I don't release the instance after adding it to my app delegate's array of viewer windows.


Here's my -[WSAppDelegate createViewerWindow:] method:

- (IBAction)createViewerWindow:sender {
    WSViewerWindowController *windowController =
[[WSViewerWindowController alloc]
initWithWindowNibName:WSViewerWindowNibName];

    [self insertObject:windowController
inViewerWindowControllersAtIndex:0];

    [windowController showWindow:self];
    [windowController release];
}

Commenting out the [windowController release] line fixes the problem,
but I don't think this is a good solution.

WSViewerWindowController's initWithWindow and dealloc methods just
call the superclass's methods and don't do anything else.

Here's my -[WSAppDelegate insertObject:] method:

- (void)insertObject:(WSViewerWindowController *)
viewerWindowController inViewerWindowControllersAtIndex:(unsigned int)
index {
    [[self viewerWindowControllers]
insertObject:viewerWindowController atIndex:index];
}

Here's my -[WSAppDelegate viewerWindowControllers] method:

- (NSMutableArray *)viewerWindowControllers {
    if (viewerWindowControllers == nil) {
        viewerWindowControllers = [[NSMutableArray alloc] init];
    }
    return [viewerWindowControllers autorelease];
}

What am I doing wrong? I'm sure it's something basic and simple.

Thanks for your help.

Ben
--
Ben Kazez
http://www.benkazez.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem with an NSWindowController's retain count
      • From: Will Mason <email@hidden>
  • Prev by Date: From Delphi to Cocoa
  • Next by Date: Re: Table bindings to objects
  • Previous by thread: Re: From Delphi to Cocoa
  • Next by thread: Re: Problem with an NSWindowController's retain count
  • Index(es):
    • Date
    • Thread