• 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: Self terminating popup window - need help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Self terminating popup window - need help


  • Subject: Re: Self terminating popup window - need help
  • From: j o a r <email@hidden>
  • Date: Fri, 15 Apr 2005 21:20:04 +0200


On 14 apr 2005, at 23.41, Dan Yocom wrote:

   I created a subclass of NSWindow that automatically closes the
window after three seconds.

That's not a good reason to subclass. Let's think of some other design.

(Cocoa developers try to avoid subclassing. We have a lot of useful alternatives to subclassing, mainly categories and delegation. Search the list archives and the Cocoa web resources (look in the regular email from list-mom Mmalc for links) for more information on these topics.)

The subclass works as it should when
called from a normal objective-C routine/function. However, if I call
it from within a NSThread I create, it will popup but not close. Does
anyone know why it won't work porpperly when call from within an
NSThread?

Yes, if you set a timer to close that window, the timer will be depending on the normal operation of the run loop in that thread. If you are doing a synchronous operation, never letting the run loop - well, run - the timer is never going to fire.


The easiest thing to do would probably be to set the timer in the main thread. Something like this (note that I expect you to already have a window called "myWindow"):

- (void) startLongOperation
{
    // Open window
    [myWindow makeKeyAndOrderFront: nil];

// Set the timer to close the window
[myWindow performSelector: @selector(orderOut:) withObject: nil afterDelay: 3.0];


// Launch operation
[NSThread detachNewThreadSelector: @selector(theOperation) toTarget: self withObject: nil];
}


j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Self terminating popup window - need help (From: Dan Yocom <email@hidden>)

  • Prev by Date: Re: dynamically allocating arrays of type double
  • Next by Date: Re: awakeFromNib not called
  • Previous by thread: Re: Self terminating popup window - need help
  • Next by thread: Re: Self terminating popup window - need help
  • Index(es):
    • Date
    • Thread