Tanner Silva
Tanner Silva

Reputation: 279

NSNumber Saving A Double

Consider the three lines of code below

NSLog(@"start:%f", player.currentTime);
episode.resumeStamp = [NSNumber numberWithDouble:player.currentTime];
NSLog(@"end: %f", [episode.resumeStamp doubleValue]);

episode is a subclass of NSManagedObject, and player is an AVAudioPlayer. player.currentTime returns an NSTimeInterval (double). One would think when the code shown above runs, the "start:" and "end:" values will be the same. Oddly enough, the following is logged...

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

Any ideas why this might be happening? Thank you so much for your time!

Upvotes: 0

Views: 149

Answers (1)

Jesse Black
Jesse Black

Reputation: 7976

episode is most likely nil

Just add update the log to

NSLog(@"end: %f\nepisode %@", [episode.resumeStamp doubleValue], nil);

Upvotes: 3

Related Questions