• 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
Re: Window closes on its own
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window closes on its own


  • Subject: Re: Window closes on its own
  • From: "email@hidden" <email@hidden>
  • Date: Tue, 06 Sep 2011 10:23:12 +0100

On 5 Sep 2011, at 21:25, Alexander Reichstadt wrote:

> I can't due to using the garbage collection.
>
> Am 05.09.2011 um 20:47 schrieb Jens Alfke:
>
>>
>> On Sep 5, 2011, at 12:08 AM, Alexander Reichstadt wrote:
>>
>>> the window created through the following code closes on its own after one second. Why?
>>
>> I’m guessing there’s an extra -release call (or insufficient -retains) and the window’s getting dealloced after the autorelease pool drains.
>>
>> Try setting a breakpoint in the -dealloc method, adding a generic -dealloc if you don’t already have one.
>>

Jens' point is still valid. Have you retained a reference to your controller object so that it is reachable?

PWSuggestionsWindowController *newCon = [[PWSuggestionsWindowController alloc] initWithWindowNibName:@"PWSuggestionsView"];
   [[newCon window] makeKeyAndOrderFront:self];

In the above snippet newCon needs to be reachable or the collector will finalise it.
Normally controller objects are referenced via ivars, often in the application delegate.
This makes them reachable via the application root (NSApp).

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcEssentials.html

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________

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: Window closes on its own
      • From: Alexander Reichstadt <email@hidden>
References: 
 >Window closes on its own (From: Alexander Reichstadt <email@hidden>)
 >Re: Window closes on its own (From: Jens Alfke <email@hidden>)
 >Re: Window closes on its own (From: Alexander Reichstadt <email@hidden>)

  • Prev by Date: Re: Long delay of NSPopUpButton first click
  • Next by Date: Re: NSBrowser column titles disappear when scrolled [SOLVED]
  • Previous by thread: Re: Window closes on its own
  • Next by thread: Re: Window closes on its own
  • Index(es):
    • Date
    • Thread