User Name
Password
AppleNova Forums » Programmer's Nook »

Mutable NSTimer?


Register Members List Calendar Search FAQ Posting Guidelines
Mutable NSTimer?
Thread Tools
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-05-07, 17:06

So, I've been writing a little app that periodically checks the CPU temperature and displays it in the menu bar. Now I'd like the user to be able to change the interval (frequency) of the gauging. I'm using NSTimer's scheduledTimerWithTimeInterval; however, it appears there is no way to change the interval later on. I figure I'm supposed to invalidate the timer and create a new one, but I'm currently at a loss regarding implementing that. Namely, it seems that the old timer doesn't immediately destroy itself, so for a short time, I have two timers running, which is definitely not what I want.

I would much prefer being able to change the original timer's interval instead, rather than having to create multiple ones. I haven't found much documentation on this, surprisingly, so I'm wondering if anyone has experience.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-05-08, 15:16

No ideas?
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-05-11, 21:54

Figured it out (by releasing and reallocating). Not necessarily happy with this solution, but whatever.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2006-05-12, 04:14

Quote:
Originally Posted by chucker
Figured it out (by releasing and reallocating).
I was going to suggest that, but I figured it was too obvious. Next time, I won't assume anything!

(Yes, I agree it's not very elegant either.)
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-05-12, 06:56

Quote:
Originally Posted by Brad
I was going to suggest that, but I figured it was too obvious.
Oh, I agree that it's obvious that it can be done that way. I was just hoping for something more elegant and was convinced that this wasn't the preferred way™. But according to #macdev, it is.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 05:29.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova