Ios – How to compare two NSTimeInterval type object

iosnstimeintervalobjective c

Some thing like this:

@property (nonatomic,assign) NSTimeInterval *startTime;

AVAudioPlayer *player;

And I want to do this

if (self.player.currentTime  > sub.startTime) {
    do something...
}

I think they are both NSTimeInterval type data, why I can't do this?

If I change the up code like this

if (self.player.currentTime  > 5) {
    do something...
}

It can works very well.

Best Answer

NSTimeInterval is just a typedef of double. It's not an Objective-C object, so you should probably not use a pointer as your property. You should just use a plain NSTimeInterval:

@property (nonatomic) NSTimeInterval startTime;