I'm just getting started with using threads in obj-c/cocoa and I'm running into some trouble.. I get this error in the console:
2010-02-15 09:18:41.467 Timer[1007:4503] *** __NSAutoreleaseNoPool(): Object 0x10012adc0 of class __NSCFDate autoreleased with no pool in place - just leaking
2010-02-15 09:18:41.478 Timer[1007:4503] *** __NSAutoreleaseNoPool(): Object 0x1003362b0 of class NSCFTimer autoreleased with no pool in place - just leaking
here is the code that creates the new thread:
// Timer
JHTimer *timer = [[JHTimer alloc] init];
[timer setMinTextLabel:minTextLabel];
[timer setSecTextLabel:secTextLabel];
[timer setHrTextLabel:hrTextLabel];
timerTimeInt = 30;
[timer setTimerInterval:timerTimeInt];
[NSThread detachNewThreadSelector:@selector(start) toTarget:timer withObject:nil];
and the code that creates the autorelease pool (and the start method that creates the timer):
- (void)main {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
}
- (void)start {
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerDidUpdate:) userInfo:nil repeats:YES];
NSLog(@"Test");
}
and I can't figure out that's wrong