• 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
Since when does caling [NSTimer invalidate] release the object that spawned it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Since when does caling [NSTimer invalidate] release the object that spawned it?


  • Subject: Since when does caling [NSTimer invalidate] release the object that spawned it?
  • From: Walt Horat <email@hidden>
  • Date: Tue, 16 Aug 2005 18:59:13 -0700

Subject says all. Code is:

- (IBAction) someMethod
{
    m_closeAlpha = 1.0;
    m_closeTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
        target:self
        selector:@selector(windowCloseFade:)
        userInfo:self
        repeats:TRUE];
}

- (IBAction) windowCloseFade: (id) sender
{
if (m_closeAlpha <= 0.0)
{
if (nil != m_closeTimer)
{
[m_closeTimer invalidate]; // invalidate our current timer
m_closeTimer = nil;
}
}
else
{
m_closeAlpha -= 0.0125; //(8 second fade)
[[self window] setAlphaValue: m_closeAlpha];
}
}



We crash on the call to invalidate. Looking up the stack, I can see it trying to deallocate the object that instantiated it (i.e. "self" in the call to create the timer). NOTE: frame #4 is the [m_closeTimer invalidate] statement. Why would invalidating my timer invalidate me?


#0 0x00023230 in -[UCSessionWindowController dealloc] at UCSessionWindowController.m:177
#1 0x93a7cccc in -[NSWindowController release]
#2 0x9288b0d0 in _timerRelease
#3 0x90772370 in CFRunLoopTimerInvalidate
#4 0x00025640 in -[UCSessionWindowController windowCloseFade:] at UCSessionWindowController.m:749
#5 0x9287fcfc in __NSFireTimer
#6 0x9075edb0 in __CFRunLoopDoTimer
#7 0x9074b728 in __CFRunLoopRun


Why, oh why... Why would it do that?


Puzzled, I remain,


Walt Horat _______________________________________________ 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: Since when does caling [NSTimer invalidate] release the object that spawned it?
      • From: "Timothy J. Wood" <email@hidden>
References: 
 >[NEWBIE] windowDidBecomeKey ? (From: Stephane Pinel <email@hidden>)

  • Prev by Date: Re: Core Data: slow saves to persistent store
  • Next by Date: ZeroLink making progress bar animation smoother?
  • Previous by thread: Re: [NEWBIE] windowDidBecomeKey ?
  • Next by thread: Re: Since when does caling [NSTimer invalidate] release the object that spawned it?
  • Index(es):
    • Date
    • Thread