Arrays are useful for storing ordered sets of data. An array in Swift stores values of the same type in an ordered list.

The same value can appear more than once in an array, each at different positions.

Create an empty array of Integers (note the square brackets)

Or an array of strings:

Now if we want to add a value to these arrays, it’s easy peasy!

Of course we don’t have to always add values like this. We can pop them in at the start:

How about counting numbers of elements in an array?

How about getting elements themselves?

And if we access an element that doesn’t exist?

That’s arrays in a nutshell. There are tons more functions but once you know the basic structure the rest is easy!

Arrays in Swift 4 Explained
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Exhausted by your 9 - 5?

Would you prefer to work for half the time and earn double? The first step to your freedom is understanding how apps make money. Simply enter your email below and I will send you a free PDF describing the process.

If you're serious about improving your life then do not miss this opportunity.


You have subscribed! Please check your email to confirm this subscription and to receive your item!