数据时,我有以下代码后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