My app allows users to add new items to their inventory. Every time an item is added, one of the properties that get associated with that item is the timestamp of when it was added. To get that timestamp, I use the following code:
float timestamp = [[NSDate date] timeIntervalSince1970];
If I add multiple items during one session of using the app (i.e., I just build & run it once, but go through the add process multiple times), the timestamp always comes out the same. Once I build and run the app again, however, the timestamp changes. But then it doesn’t change again until I re-build & run.
I know it’s not a problem of storing the item data, because if I log the timestamp variable (rather than just looking at the item’s timestamp property), I see this failure to change.
Why isn’t it changing?
In case it matters, I’m running this on the iPhone simulator.
-[NSDate timeIntervalSince1970]return aNSTimeIntervalnot afloat.