//
you're reading...

Programming

Swift Snowflake ID Generator

Creating unique identifiers is tricky. More if you can’t have locking or a global service which doles out numbers in a sequence.

Sure there is the 128-bit UUID that should almost always generate a unique identifiers with a tiny probability of clashing – the odds of generating duplicate UUID values are like finding two grains of sand having the same shape. However these values are large and difficult to handle unless converted to string. Moreover there is no ordering guaranteed on those randomly-created UUID values.

What if I say that you can create unique identifiers that are ordered, unsynchronized, yet stay within a 64-bit integer data type? Unlike UUID types, these values can be stored and processed efficiently by many programming languages without needing stringification.

I’ve covered this in a lightning talk in iOS Conference Singapore on 19 January 2019.

Special thanks to Engineers.SG for capturing the video and publishing it.



Avoid Delays and Rejections when Submitting Your App to The Store!


Follow my FREE cheat sheets to design, develop, or even amend your app to deserve its virtual shelf space in the App Store.

* indicates required

When you subscribe you’ll also get programming tips, business advices, and career rants from the trenches about twice a month. I respect your e-mail privacy.

Discussion

No comments yet.

Leave a Reply