• 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: NSTimer fires after invalidated - why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer fires after invalidated - why?


  • Subject: Re: NSTimer fires after invalidated - why?
  • From: Walt Horat <email@hidden>
  • Date: Wed, 22 Mar 2006 22:38:18 -0800
  • Thread-topic: NSTimer fires after invalidated - why?

Let's just call this one a big "nevermind" since the if statement seems to
prevent subsequent calls to NSTimer invalidate... It works as intended if
you remove the whole if statement! Where is the unsend-to-list feature when
you need it!

I do appreciate the efficiency of implementing this, as with most things
cocoa, it is trivial to make the framework do what I want.

 -Walt
-----

On 3/22/06 8:19 PM, "Walt Horat" <email@hidden> wrote:

> If a particular drawer is concealed when the user types, we want to open the
> drawer and have it close after a period of time; each keystroke shall reset
> the timer.
>
> The following code does not work, while to my understanding it should. What
> is wrong with my understanding?
>
> -(void) keyDown: (NSEvent*) theEvent
> {
>     ...
>     ...
>
>     if ([m_drawer state] != NSDrawerOpenState)
>     {
>         [ m_drawer open];               // open, if not already
>
>         [m_drawerCloseTimer invalidate];    // " Stops the receiver from
>                                             // ever firing again and
>                                             // requests its removal from its
>                                             // NSRunLoop"
>         [m_drawerCloseTimer release];
>
>         m_drawerCloseTimer = [[NSTimer scheduledTimerWithTimeInterval: 5.0
>                                        target: m_drawer
>                                      selector: @selector(close:)
>                                      userInfo: nil
>                                       repeats: NO] retain];
>     }
> }
>
> We start with a nil timer, so the first time through the invalidate and
> release are no-ops.
>
> We allocate a timer to fire 5 seconds in the future; the timer is wired
> directly to the drawer close.
>
> The actual behavior is that the drawer closes 5 seconds after the first
> keypress, regardless of any keystrokes that occur in the interim.
>
>
>
> Walt
> Cisco Systems
>
>  _______________________________________________
> 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

 _______________________________________________
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: NSTimer fires after invalidated - why?
      • From: Andreas Mayer <email@hidden>
References: 
 >NSTimer fires after invalidated - why? (From: Walt Horat <email@hidden>)

  • Prev by Date: Re: value transformer for structs?
  • Next by Date: Re: value transformer for structs?
  • Previous by thread: Re: NSTimer fires after invalidated - why?
  • Next by thread: Re: NSTimer fires after invalidated - why?
  • Index(es):
    • Date
    • Thread