Re: Timers in a Foundation Tool
Re: Timers in a Foundation Tool
- Subject: Re: Timers in a Foundation Tool
- From: Jeff Harrell <email@hidden>
- Date: Fri, 4 Jul 2003 16:06:22 -0500
NSRunLoop!
I ran into a similar problem recently with a threaded AppKit
application. I'm not sure it's the case with this application, but I'm
willing to suggest it anyway. You may need to manually start a run loop
before your thread will fire.
[[NSRunLoop currentRunLoop] run];
should do the job. The +currentRunLoop method creates a run loop is
none yet exists.
On Friday, July 4, 2003, at 03: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.
Any input is greatly appreciated.
Sincerely,
Brian Ganninger
#import <Foundation/Foundation.h>
void launchEngine()
{
NSLog(@"Hello again...");
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2
target:nil selector:launchEngine() userInfo:nil repeats:TRUE];
sleep(1000);
[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.
--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
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.