AppMakers.DEV
Published in

AppMakers.DEV

How to pick a random element from an array (Swift)

In this tutorial, you will learn how to pick a random element from an array using Swift.

You will Need Mac, the latest Xcode to complete this tutorial.

This story was originally published on AppMakers.Dev

Open Xcode and create a new playground titled “How to pick a random element from an array using Swift”

Create an array and run the randomElement() method on it.

Run and see the results

Keep in mind that at the moment of writing this post we used Xcode 11 and Swift 5.
If anything will change in the future, it is OK, just use the new API calls for the functions mentioned in this post.

Thanks for reading.
If you love this post, feel free to clap 👏👏 and share it.

🏷 COURSE DISCOUNT: Learn more about Table Views in the NEW UITableView Swift 5 Course

Related Posts:
Best iOS Development Podcasts for App Developers

Visit AppMakers.Dev Website for interesting posts about App Development. Follow the Editor

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store