數據時,我有以下代碼後5秒通過特定的ID:應用程序崩潰試圖通過在的NSTimer
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSNumber numberWithInteger:currentID] forKey:@"ID"];
timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(checkID:) userInfo:dict repeats:NO];
- (void)checkID:(NSTimer*)t{
NSInteger timerID = [[[t userInfo] objectForKey:@"ID"] integerValue];
if (timerID == _myID){
NSLog(@"got ID");
}
}
但我的應用程序只是崩潰計時器結束後。有任何想法嗎?我在四處尋找幫助,但我只能找到上面的代碼,顯然它適用於其他人。
謝謝
ARC或MRC?如果你不使用ARC,那麼你應該釋放字典。 – 2013-03-23 22:45:48
'timer'的範圍是什麼?這裏很難說。 – 2013-03-23 22:46:34
這段代碼沒有錯,它對我來說工作得很好。不用DigiMonk在他的回答中寫的名字是好的,但那不是解決你的問題的方法。你還改變了別的嗎? – rdelmar 2013-03-23 23:50:46