I want to nslog the device motion timestamp property .
The device motion is in the class CMMotionManager.devicemotion.timestamp
Any ideas.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit: Please see Nicolas Lauquin’s answer. Per the comments, the following solution is not correct but is retained here for history (and because I can’t delete it since it is currently marked accepted).
The
timestampproperty is anNSTimeInterval, so you should be able to do:NSTimeIntervalis just a typedef’ddoubletype, so you could use%finstead of%@and log it directly.Also, the docs don’t indicate whether this timestamp is set against Apple’s reference date or the standard *nix date, so you may need to use
[NSDate dateWithTimeIntervalSince1970:]if the aforementioned method returns dates far in the future.As @davidbitton has suggested the
CMDeviceMotion‘stimestampis relative to the last device boot, the correctNSDatecould be derived byThis should yield a roughly accurate
NSDateobject, assuming @davidbitton is correct. (reference: NSProcessInfo -systemUptime)However, given how complicated this is, I would now suggest for simplicity that, given the nature of the
timestampproperty, that you log it in a format string as something like