• 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
how to release my window controller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to release my window controller


  • Subject: how to release my window controller
  • From: Torsten Curdt <email@hidden>
  • Date: Sat, 2 Aug 2008 17:23:08 +0200

Hey guys,

Let's say in my AppController a new Non-modal window is getting opened like this

 -  (IBAction) buttonOpen:(id)sender
 {
	MyWindowController *controller = [[MyWindowController alloc] init];
	[controller showWindow:self];
 }

Of course I will have to release the controller at some stage. Now there are a couple of ways doing this:

1. Inside the window controller call [self close]; [self release];

Not really sure this would actually be OK as the release could happen to soon.

2. Inside the window controller [self close]; [self autorelease];

This would delay the release of the controller.

But with both methods the AppController class does not have any idea the window got closed (and released). Which can be a problem if you want to act on this event. So there is another option:

3. Create a showWindow: andCallOnClose: and pass in a selector and then call the selctor on close

 -  (IBAction) buttonOpen:(id)sender
 {
	MyWindowController *controller = [[MyWindowController alloc] init];
	[controller showWindow:self andCallOnClose:@selector(windowClose:)];
 }

- (void) windowClosed:(id)controller
{
	[controller release];
}

But I wouldn't be surprised if there was an easier way of doing this. Is there?

cheers
--
Torsten
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: how to release my window controller
      • From: Chris Hanson <email@hidden>
    • Re: how to release my window controller
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
  • Next by Date: Re: My own listbox
  • Previous by thread: Re: Non-editable TableView and the Evil NSEditorBinder
  • Next by thread: Re: how to release my window controller
  • Index(es):
    • Date
    • Thread