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

Get your FREEapp monetisation flowchart!

Use our epic flowchart to help you find the money in your idea! If you're thinking of making an app then this is vital information!

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