5

The documentation of SKScene -update is as follows: doc

What exactly is "the current system time," and how can I get it other than via SKScene -update?

I've tried CFAbsoluteTimeGetCurrent(), but apparently that

Returns the current system absolute time[, which is] is measured in seconds relative to the absolute reference date of Jan 1 2001 00:00:00 GMT.

and is not the same thing as "the current system time," which, according to my tests, has a value that is several orders of magnitude less than the "current absolute time."

Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148
Michael Dorst
  • 8,210
  • 11
  • 44
  • 71

1 Answers1

1

assign the currentTime from update: to an ivar then you have it available anywhere for the current frame. Note that while time passes on while the frame is being processed you should only work with the current frame's reference time passed into update: throughout the frame.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • 1
    I could do that, but I was really looking to get the "current system time" at the beginning of the program, and then use it as a reference for how long the program has been running. That would require me to conditionally assign from `update` on the first frame only, and that just seems like a hack. There must be a method somewhere that just returns the "current system time." – Michael Dorst Jul 19 '14 at 19:55
  • oh there is (several ways) but you can't expect that time to be related to the update time. http://stackoverflow.com/questions/358207/iphone-how-to-get-current-milliseconds – CodeSmile Jul 19 '14 at 20:57
  • Those methods all return the time interval since 1970, which is an even larger number than `CFAbsoluteTimeGetCurrent()` returns, which, as I stated, is larger than the `currentTime` passed to `update`. You may be right, but I doubt that Apple would have labeled `currentTime` "The current system time" if it was unrelated to any other accessible metric. They would probably have said "some arbitrary value that increases over time" if that were the case. – Michael Dorst Jul 19 '14 at 21:07
  • I don't know where currentTime comes from but if you need that assign the very first scene's update:currentTime to a global variable, if you also store say the interval1970 at the same time you know how they relate to each other – CodeSmile Jul 19 '14 at 21:18