Re: Timers in a Foundation Tool
Re: Timers in a Foundation Tool
- Subject: Re: Timers in a Foundation Tool
- From: Shawn Erickson <email@hidden>
- Date: Fri, 4 Jul 2003 15:12:25 -0700
On Friday, July 4, 2003, at 01:52 PM, Brian Ganninger wrote:
Dear List,
Sorry if this is a repeated question, but after searching the archives
for 2 hours I give. I have a foundation tool that I want to leave
running with a timer that fires every minute. Below is the non-working
test code I strapped together. I can't figure out how to target the
timer so it'll call the launchEngine companion method.
Updating your code snippet, the below tool will never exist on its own
as coded.
(You could also do the below using just a simple while loop with sleep.)
#import <Foundation/Foundation.h>
@interface MyEngine : NSObject {
}
- (void)launchEngine;
@end
@implementation MyEngine
- (void)launchEngine
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello again...");
[pool release];
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[NSTimer scheduledTimerWithTimeInterval:2 //switch to 60, for one
minute
target:[[[MyEngine alloc] init]
autorelease]
selector:@selector(launchEngine)
userInfo:nil
repeats:TRUE];
[[NSRunLoop currentRunLoop] run]; // thread will stay in this
call...
[pool release];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.