Swift Questions and References

In February, I joined a new start-up to help them build a mobile app for Food market. When I was onboarded, I was assigned to an existing iOS project using Swift. In this post, I noted all the questions and references I found during the time I was adapting to that project.

1. What is the “required init” decoder?




2. What is the difference between let and var in Swift?

Source: Stackoverflow

The let keyword defines a constant:

let theAnswer = 42

The theAnswer cannot be changed afterward. This is why anything weak can’t be written using let. They need to change during runtime and you must be using var instead.

The var defines an ordinary variable.

What is interesting:

The value of a constant doesn’t need to be known at compile time, but you must assign the value exactly once.

Another strange feature:

You can use almost any character you like for constant and variable names, including Unicode characters:

let 🐶🐮 = "dogcow"

3. What is optional in Swift?


Tagged : / /