Written by Paul Hudson @twostraws
Description: Let GameplayKit help you generate random numbers in ways you soon won't be able to live without.
Choosing a random number source: GKARC4RandomSource and other GameplayKit options
Shaping GameplayKit random numbers: GKRandomDistribution, GKShuffledDistribution and GKGaussianDistribution
Shuffling an array with GameplayKit: arrayByShufflingObjects(in:)
I put together answers for over 600 of the most frequently asked questions I received from readers into one place: the Swift 5 Knowledge Base. It answers basic and advanced questions, and provides lots of free code you can re-use however you please. If you hit problems, try searching there first.
If you're still having problems, you can post to the Hacking with Swift subreddit where you can expect an answer fairly quickly, or you can find me on Twitter where I'll do my best to help.
The project files for Hacking with Swift are all available on GitHub, where you can view them, fork them, or download them: click here for the GitHub repo.
SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Link copied to your pasteboard.