Hallo allemaal, Leo hier. The topic today is learning Swift language.

This will be the second post of the series How to Start iOS Development Career. It is very important to read first that post so you can understand the knowledge body we are constructing here.

An article about learning Swift is something that talks to me. My father was and my mother is a teacher and learning was a common subject of countless conversations when I grew up. There is a whole world of how people learn (children and adults), and it is not the scope of this article to go deep into the science behind learning or any scientific approach to learning.

The subject here is the path I took to learn Swift. And how I continue to learn every day. Learning Swift is an ongoing task, simply because we end up forgetting some things and the language itself evolves every year. This way we are forced to always sharpen our pencils.

This article is the most important of all in this series. This article is the ground on which we will build our iOS career, keep in mind that not mastering Swift will always limit your development as an iOS developer.

All the resources here are completely free and I always recommend before paying for courses, dig around for all free content, and then after months of studying free content you have a more educated opinion on what course you should take, and in my case, I always enjoy more the paid content if I study free resources first.

Today I’ll give you the techniques I used and how you could apply them to your process of learning Swift.

Let’s go! But first…

 

Painting of The Day

It is pretty rare but this is one of those articles that I found the perfect image for it.

This is a wood engraving from a Bookplate D.H. Roodhuyzen de Vires van Dishoeck by the legendary Maurits Cornelis Escher. He lived from 1898 to 1972 and was a Dutch graphic artist who made mathematically inspired woodcuts, lithographs, and mezzotints.

His work features mathematical objects and operations including impossible objects, explorations of infinity, reflection, symmetry, perspective, truncated and stellated polyhedra, hyperbolic geometry, and tessellations. Although Escher believed he had no mathematical ability, he interacted with the mathematicians George Pólya, Roger Penrose, Harold Coxeter, and crystallographer Friedrich Haag, and conducted his own research into tessellation.

This engraving is perfect because is a monk studying a book and the phrase in the window represents the motto of this post: Labore et Constantia, which means labor and constancy, and that is an amazing coincidence because they are two things that you will definitely need to learn Swift.

 

The Problem – Learning Swift Language

You want to learn Swift programming language.

When I started to learn Swift I was already a Java developer for 7 years. This is very important to make it very clear because I didn’t have to learn algorithms, OO, or any other basic programming concept.

That said let us dive into today’s topic. The first thing to understand here is that learning Swift is a never-ending journey. I learn new stuff EVERY single day. No joke. This is something that I don’t think I would ever say: I know everything. Even excellent Swift full-time writers like Paul Hudson have a whole video about Who can say they learn Swift?. And he is right. This is and will be something for your whole iOS development life.

Putting your head state into learning Swift could be a cold bath when you fall in love with iOS development because you are not starting to build apps right away. Be assured of this: the faster you understand Swift, as fast you will be an iOS developer. Being comfortable writing Swift code is a prerequisite for anyone who wants to join the iOS path.

I made a lot of interviews with candidates that lacked basic Swift knowledge even being seniors/Leads in their current positions.

One last thing, learning Swift is not easy. Don’t overlook this first step thinking that you learn how to declare a String and you are done. Dive into this and give them time to process how Swift works and how programming with Swift works. Also, I’ll not compare Swift with other languages because this is not the scope of this article.

 

The Two Resources

In my initial days, I used two main resources. The 100 days of hacking Swift series and the Apple’s Swift Programming Book. Those two resources should be enough to give you a really clear view of what you should expect of yourself in this step. Especially the final quizzes of the first 15 days of Paul Hudson’s course.

I started with the first 15 days of the 100 days of hacking Swift series. When I’m mentoring new people I always tell them to make this first 15 at least TWO TIMES, three would be excellent. This course is very good because of two things: I think Paul is an amazing teacher and you have quizzes in it where you can practice your recently acquired knowledge.

While doing the first 15 days of the above-mentioned course, I would recommend reading [Apple’s Swift Programming Book](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html) by yourself. What I did at the time was: doing a day that explain functions I would search in the book the article about functions.

But if you are a video-oriented person, you can see this video where he explains all the basics of the Swift language.

All in all, you should stay in this phase as long as you need to fully understand almost any code example in StackOverflow, at least at the language level. Of course, you won’t know what every Apple API is doing but you must be able to read a code and be clear on what is going on.

 

Two Learning Techniques

To help me in this part I have two techniques. Here we will extensively use deliberate practice techniques. In a nutshell, you will not mindlessly repeat exercises, instead, you will take conscious efforts each time you are learning Swift. I always say that you need to “Measure Twice, Cut Once“, this is not related to woodworking (although it could) but to think before acting and almost as important thinking while you are doing the new skill.

The more you think while you are doing your study faster you will be comfortable using Swift language to express yourself through code.

 

Saying Out Loud

The first one is every time I see a code I try to translate it into a natural language for me saying OUT LOUD. Just warn the people around you that you are studying and not just talking by yourself. This is step is to try to not make things with muscular memory when learning Swift language or just copy-pasting code. Instead, you have to think about each of the lines you wrote.

For example:

let nameList = ["Aninha", "Mike", "Pep", "Alan"]

var mappedNames = nameList.map { $0.count }

print(mappedNames)

In those three lines, I would say aloud: ” In the first line I’m creating an Array struct of type String and associating it to the constant called nameList. In the second line, I’m using the Array’s map function to map each element of the nameList Array to an Integer and associating it to a variable called mappedNames, the dollar sign is a reference for the first element of the closure that will run for each value in nameList and count is a string property that holds the number of characters that each entry has. The last thing I’m printing in the console is the variable mappedNames.

Why this is important in the beginning? Because this is called deliberate practice and is one useful thing when you are trying to understand something deeply or want to evolve a skill you already have.

 

Playground Daily Exercise – Learning Swift Language

The second thing that I did was create a Swift Daily Exercise Playground for me. What was the purpose of that? For every new concept I learned, I added more or less one comment line of that concept in a playground file and implement that concept.

For example, imagine that you are learning how to declare variables and constants in Swift. I would add in the file something like this:

// Variables - I can change the value after set for the first time
var name: String = "Leo"
print(name)
name = "Mike"
print(name)
name = "Pepijn"
print(name)

// Constants - I can only set one time, that's why is a constant.
let name = "Leo"
print(name)

The important part is at the end of each day you ERASE all the code implementations you did that day. So the file above would be like this at the end of the day:

// Variables - I can change the value after set for the first time

// Constants - I can only set one time, that's why is a constant.

This way the next day I can again study all the concepts I learn in my previous days and keep everything fresh in my memory. The important part of the process is each day when you are doing your daily Swift language exercises you always think when you are doing the exercises because is tempting just to create a muscular memory of the concepts and stop thinking. Pay attention to that.

And if you are curious about how my Daily Study playground lookalike at the end of my studies, the last version looks like this:

// array, - get, set , for enumerated , [[]]

//set ,- get set

//dictionary - get set

//enum - case iterable - for , implicitly assigned raw value , recursive enums

//class init? , deinit , computed property , lazy

//struct - mutating

// function - variadic parameter , in out

//closure - as a var, as a parameter, as a return of a function, trailing closure

After every comment, I need to use the Swift features. So every day, I would practice writing at least all those features. Every… Single… Day.

I can’t stress enough how important this is step and you really should take the time to understand what is going on in every line of code that you read and write while learning Swift language.

 

Non-Beginners Applying this Technique

You can apply the techniques above-mentioned techniques to anything new you want to learn. It is not necessarily a technique for begginers.

For example, you want to learn the Combine framework. You can create a file like this:

// create a subject, send values, and sink

// create a Future

// use receive on and subscribe to different threads

// create Passthrough and CurrentValue subjects

// Use Just

// handle errors

// map objects and print results

// combine multiple publishers

And so on. This way you can everyday study the concepts of what you want to learn and you will be dependent on your environment to learn whatever you want!

 

Summary – Learning Swift Language

In today’s article we walk through all the techniques I used to start learning Swift. I hope that really helps the ones at the beginning of their career. We talked about the “Saying out loud” and “Daily Practice” techniques that I used at the beginning of my journey. I’m really interested in hearing from you about what kind of strategies did you use to become an iOS developer.

Next week we will talk about how to start studying how to make screens and flows. And I will give my 5 cents on UIKit vs SwiftUI. If you are interested in that don’t miss next week’s article!

That’s all my people, I hope you liked reading this article as much as I enjoyed writing it. If you want to support this blog you can Buy Me a Coffee or leave a comment saying hello. You can also sponsor posts and I’m open to freelance writing! You can reach me on LinkedIn or Twitter and send me an e-mail through the contact page.

Thanks for reading and… That’s all folks.

Credits:

title image