考虑下面的三行代码
NSLog(@"start:%f", player.currentTime);
episode.resumeStamp = [NSNumber numberWithDouble:player.currentTime];
NSLog(@"end: %f", [episode.resumeStamp doubleValue]);
episode
是 NSManagedObject 的子类,而 player 是AVAudioPlayer
. player.currentTime
返回一个NSTimeInterval
(双)。有人会认为当上面显示的代码运行时,“start:”和“end:”值将是相同的。奇怪的是,记录了以下内容......
2012-09-30 20:13:02.941 MyApp[473:303] start:3.809116
2012-09-30 20:13:02.942 MyApp[473:303] end: 0.000000
2012-09-30 20:13:03.941 MyApp[473:303] start:4.809048
2012-09-30 20:13:03.942 MyApp[473:303] end: 0.000000
2012-09-30 20:13:04.941 MyApp[473:303] start:5.809116
2012-09-30 20:13:04.942 MyApp[473:303] end: 0.000000
任何想法为什么会发生这种情况?非常感谢您的参与!