0
我试图找到两个NSDates之间的差异。这工作了一次,并打印出差异,但从未再次工作。我不记得有一次它工作后改变了任何事情。有任何想法吗?哦,它不会抛出一个错误,如果我注释掉这个片段一切正常。iPhone timeIntervalSinceDate没有抛出错误,或工作
//----------- Touches Begin
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
touchBegins = [NSDate date];
NSLog (@" Tap: %d ", tapTotal);
NSLog (@"<=========================>");
NSLog (@"Method: touchesBegines & Ends");
NSLog (@" Touch Begin: %@", touchBegins);
// [self updateLabelsFromTouches:touches];
}
//----------- Touches End
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
touchEnds = [NSDate date];
NSLog (@" Touch Ends : %@", touchEnds);
@try {
NSLog(@"%@", touchEnds);
NSTimeInterval elapsed = [touchEnds timeIntervalSinceDate:touchBegins];
NSLog (@" Finger Down: %f", elapsed);
} @catch (NSException *ex) {}
NSLog (@" ");
[self updateLabelsFromTouches:touches];
}
控制台:
[Session started at 2010-10-27 10:27:18 -0400.]
Tap: 0
<=========================>
Method: touchesBegines & Ends
Touch Begin: 2010-10-27 14:27:22 GMT
Touch Ends : 2010-10-27 14:27:22 GMT
谢谢,我会检查出的链接。 %f似乎没有帮助,但它是朝着正确方向迈出的一步:) – rd42 2010-10-27 14:08:29
你是否100%确定touchEnds不是零?尝试添加'NSLog(@“%@”,touchEnds);'在那里以及 – deanWombourne 2010-10-27 14:25:14
是的,它不是零,它被设置在那之上几行。我添加了更多的代码和一个控制台,上面提到了这个问题。谢谢你的帮助。 – rd42 2010-10-27 14:30:03