アプリでいくつかのクラッシュが発生しています。ログを確認してatosを使用すると、クラッシュが発生した場所が正確にわかります。これは、NSRunLoopを実行するように指示する場所です。
/**
* Create a new thread for the timer
*
* @version $Revision: 0.1
*/
- (void)createTimerThread {
NSThread *timerThread = [[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:nil];
[timerThread start];
[timerThread release];
}//end
/**
* Start the actual timer
*
* @version $Revision: 0.1
*/
- (void)startTimerThread {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
// Start timer
self.countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateCounter:) userInfo:nil repeats:YES];
[runLoop run];// <--- Crash happened here
[pool release];
}//end
/**
* Update the counter
*
* @version $Revision: 0.1
*/
- (void)updateCounter:(NSTimer *)theTimer {
// Does tons of timer stuff here
}//end
ご覧のとおり、クラッシュが発生して[runLoop run]
いますが、その理由はわかりません。これは通常、createTimerThread メソッドを 2 回目に呼び出したときに発生します。
ここで何が間違っていますか?私がやりたかったのは、バックグラウンドでタイマーを実行して、UILabel
.
Grand Central Dispatch (GCD) のような新しいものを使用する必要がありますか?