SwiftTips

ARC & when to use strong, weak, unowned

Memory management is one of the important concept when it comes to mobile application development. Memory leaks and app crashes are very common due to poorly managed memory in iOS apps. In this short article, I will describe ARC and…

What is given-when-then testing in Swift?

Given-When-Then (GWT) is a structured way to write unit tests. I find it is particularly useful when I need to write complex unit tests. The structure helps me to write and understand unit test faster than the traditional approach. Using this…

What does the associated type mean in Swift 5+?

The associated type in Swift gives a placeholder name to a type that will be used as part of the protocol. When the protocol is conformed, the actual type to use for that it is specified. The associated type makes the protocol generic by…

Grasp mutating function in Swift under three minutes!

The understanding of the mutating function depends on the understanding of reference and value types. In Swift, The properties of value types cannot be changed within its instance methods by default. You need to use a mutating keyword in the…

How to use DispatchGroup in Swift?

DispatchGroup allows you to add a set of tasks and schedule them for asynchronous execution. This behaviour can be helpful when progress can’t be made until all of the specified tasks are complete. For instance, If you have several long-running…

Optional methods in protocols

In Swift, If you conform to a protocol you need to implement all its methods or properties. Optional methods are not allowed when implementing protocols. For instance: We can try some tricks to make the optional methods. Use default implementation…