Let's build a basic Stack data structure with Swift. We will have to cover a couple of core concepts: Generics in Swift, and Basic Stack operations. Let's get started!

First, let us create the basic data structure that we will add to

class Stack<T> {}

Things to know about the code above:

  1. We define a new Swift class called Stack
  2. The Stack class is parameterized by some type T as denoted by <>

We will see shortly how the Type T is going to help us.

Now let us add the two basic operations of our Stack

class Stack<T>…

In SwiftUI, views can keep state, meaning they can describe the content of the view in terms of the current state of some property inside of the view. Use the @State property wrapper before any property in a view struct to mark it as a state variable.

The code above creates a small view that keeps track of the number of times that the button is pressed. This is achieved by marking the count variable with the State property wrapper, this tells SwiftUI that anytime that the value of count changes that it should re-draw the view. …


Devtember !

So it’s easy to get into ruts right? We go to class, we come home, we eat, we do our homework, and that’s it. By doing this the only thing we learn about development is what is taught to us in class. All of this is important of course, but there is a whole world of technologies and frameworks out there that could be industry standard by the time we graduate, and we’ll have never heard of them! I’m Jared, I am in my final stretch of college for computer science, and I figure now is as good…

Jared Jarvis Williams

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