Re: Refresh
Re: Refresh
- Subject: Re: Refresh
- From: Todd Yandell <email@hidden>
- Date: Thu, 10 Feb 2005 13:48:13 -0600
Hi,
You just need to setup a timer that will refresh your view every few seconds. This is done with the NSTimer class. Basically, you need to set up a timer with a certain interval as your refresh rate, give it a selector (function pointer) and then schedule the timer with your run loop. Or, for convenience, the
scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: method will handle all of that for you. Here's an example:
<x-tad-bigger>- (</x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger>)awakeFromNib
{
</x-tad-bigger><x-tad-bigger>// Setup a three-second timer than calls 'refresh:'.</x-tad-bigger><x-tad-bigger>
</x-tad-bigger><x-tad-bigger>// The 'timer' should be an NSTimer instance variable.</x-tad-bigger><x-tad-bigger>
timer = [[NSTimer scheduledTimerWithTimeInterval:</x-tad-bigger><x-tad-bigger>3.0</x-tad-bigger><x-tad-bigger>
target:</x-tad-bigger><x-tad-bigger>self</x-tad-bigger><x-tad-bigger> selector:</x-tad-bigger><x-tad-bigger>@selector</x-tad-bigger><x-tad-bigger>(refresh:)
userInfo:</x-tad-bigger><x-tad-bigger>nil</x-tad-bigger><x-tad-bigger> repeats:</x-tad-bigger><x-tad-bigger>YES</x-tad-bigger><x-tad-bigger>] retain];
}
- (</x-tad-bigger><x-tad-bigger>void</x-tad-bigger><x-tad-bigger>)dealloc
{
[timer invalidate]; </x-tad-bigger><x-tad-bigger>// Stop the Timer</x-tad-bigger><x-tad-bigger>
[timer release]; </x-tad-bigger><x-tad-bigger>// Release the Timer</x-tad-bigger><x-tad-bigger>
[</x-tad-bigger><x-tad-bigger>super</x-tad-bigger><x-tad-bigger> dealloc];
}
- (</x-tad-bigger><x-tad-bigger>id</x-tad-bigger><x-tad-bigger>)sender
{
</x-tad-bigger><x-tad-bigger>// Reload Image Here</x-tad-bigger><x-tad-bigger>
}</x-tad-bigger> _______________________________________________
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: | |
| >Refresh (From: Joe Maffia <email@hidden>) |