I am making a quiz game for iOS and I need a way to identify which game is which. Can I use the .timestamp() or is there a chance that two games could end up with the same timestamp value?
Asked
Active
Viewed 155 times
0
-
If you have a limited amount of users this will be no issue. But when you have millions of users you will have collisions. Some caution is needed when working with timestamps across front-end / back-end and across multiple front-end timezones. If you do not make sure every device is creating timestamps in UTC 00, you will have weird results. – R Menke Apr 01 '16 at 10:00
-
A better way to create identifiers is to generate UUID's [Q/A on UUID](http://stackoverflow.com/questions/24428250/generate-uuid-in-xcode-swift) – R Menke Apr 01 '16 at 10:01
-
@RMenke that seems to be a good way to do it, thanks! – Tom Fox Apr 01 '16 at 11:40
1 Answers
2
A better way to create identifiers, as suggested by @RMenke is to use NSUIID().UUIDString
...
For example
let uuid = NSUUID().UUIDString
print(uuid)

Tom Fox
- 897
- 3
- 14
- 34