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