Beginner Tutorial for SwiftUI

Swift Arrays are a collection where each item uses a numerical index. Code below returns the value “signs”

var categories = ["signs","roads","behaviour"]
categories[0]

With Dictionary instead of using numerical indexes, you can specify a unique key. Code below returns the value “signs”

var categories = ["basics" : "signs", "intermediate": "roads", "advanced":"behaviour"]
categories["basics"]

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.