Swift

What is Copy On Write(COW) in Swift?

Copy-On-Write (COW) is a memory management technique used in Swift programming language to optimize the performance of memory allocation and deallocation operations. In COW, whenever a new instance of a data structure is created, the original data structure is not…

Xcode Cheat Sheet – Most used shortcuts and tips

If you’re an iOS developer, it’s essential to have a thorough understanding of the tools you use on a daily basis. After all, you likely spend 40 or more hours a week working with them, so knowing small hacks that…

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…

Why should you use private outlets by default?

Access control is very powerful concept in object oriented programming language. Access control helps prevent you from using objects in ways they were not intended to be used. Access control lets you carefully control what properties and methods an entity…

Swift iOS interview questions and answers

Swift is a very powerful language and it combines both object-oriented and functional programming. It has many exciting features such as closures, function pointers, tuples, and multiple return values, generics, functional programming patterns, etc. In this article, I have collected…

Use of #file, #line, #function when debugging

#file, #line and #function are very common to debug features that are available in other languages like C++. I found it very useful to implement debug/logging manager. We can get the current file name, line number and function name from…

How to use defer in Swift?

Using defer keyword in Swift code is uncommon. But, It is a very powerful concept for certain use case. The code block inside defer statement is executed just before transferring program control. It does not matter how program control is…

How and when to use typealias in Swift?

The typealias is a simple but powerful concept in Swift. Type alias does not create new types. They simply provide a new name to an existing type. It makes long, compound types easy to manage. In Swift, we are passing…

First-class functions in Swift

First-class functions are the core feature of a functional programming language. Swift isn’t a functional programming language. But, it has the power of first-class functions. In this short article let’s have a look at the first-class functions and their application.…

Map, FlatMap, Filter, Reduce – High order functions in Swift

Higher-order functions are used a lot in functional programming. A higher-order function is a function that takes one or more functions as arguments and returns a function or a value as its result. All other functions are first-order functions. Higher-order…

Use of final keyword in method and class

The Final is a class modifier that prevents it from being inherited or being overridden. While writing an API developer might have a class in the framework that can be abused or misused when subclassed. The solution will be the…