-2

I use [NSDate date] to get user's system time, but if the user changed system date/time, I'll get a error date. How can I solve this problem?

ps : [NSDate date] is the only way to get the date from user's iPhone, and user has no network.

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
ZeroChow
  • 422
  • 2
  • 5
  • 16

2 Answers2

1

You can't prevent the user from changing the system date or time.

Michael Graff
  • 495
  • 1
  • 4
  • 14
0

As an auxiliary measure, you can get true time from server when network is accessible. That is, when app has access to network, don`t trust in local system time. However, that is just merely an assistant measure. It can not be sure that network is always connected. In my opinion, in summary, there is no absolute way to prevent system data changing, but we can use server time to weaken its negative effect.

ZilinWeng
  • 63
  • 8
  • thanks. I thought of another solution, if can be solved with timer?I from a timer to get time without ` [NSDate date] ` get time – ZeroChow Dec 28 '15 at 03:49