我在与分配一个NSTimeInterval值一个NSNumber块中投NSTimeInterval为NSNumber的
这里块内的困难是什么,我到目前为止有:
[player addPeriodicTimeObserverForInterval:CMTimeMake(3, 10) queue:NULL usingBlock:^(CMTime time){
NSTimeInterval seconds = CMTimeGetSeconds(time);
NSNumber *lastTime = 0;
for (NSDictionary *item in bualadhBos) {
NSNumber *time = item[@"time"];
if (seconds > [time doubleValue] && seconds > [lastTime doubleValue]) {
lastTime = [seconds doubleValue];// this line causes difficulties
NSString *str = item[@"line"];
break;
}; }
}
我在NSNumber中记录时间,当if语句为真时,我需要为变量lastTime指定一个新值 - 问题是我似乎无法弄清楚如何为变量赋值一个NSTimeInterval值lastTime是NSNumber类型的。我感到非常困惑,因为我读的所有内容都告诉我,两者都只是双打。有任何想法吗?
NSTimeInterval只是标量/基元'双'类型的别名,而NSNumber是一个类。您不能在Objective-C中的标量和对象之间“投射”。 – 2014-09-23 23:10:48