Floyd’s Cycle detection algorithm or Hair Tortoise algorithm is used to detect if there is a cycle in a linked list. This algorithm is quite confusing if not analyzed mathematically.

If you are aware of the algorithm and want to check only the WHY, jump to the proof section.

What is a Linked List Cycle?

A linked list is said to have a cycle if the end of the linked list points to another node of the list.

What is Floyd’s Cycle detection algorithm?

Floyd’s Cycle detection algorithm is used to detect whether the linked list has a cycle in it and what is the starting point(green node in the above diagram)…

MVVM is the acronym for Model-View-ViewModel. It is an architectural pattern that primarily focuses to provide a clear separation between the core components of your app. MVVM is composed of the following components:


Model is basically the data model or entities that your application has. They are simply structs or classes with simple associated properties. In general practice, they hold the data that has been mapped from your raw data structure which might come from your API’s or other sources such as SQLite files, etc. The view model owns the model


The view is the visual element that…

While writing SwiftUI views, you might quickly come across an error which says

Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type

When does such an error happen?

A view body in SwiftUI goes like

var body: some View {
Text("Hello, World!")

The body is a computed property returning an Opaque type of a View type. The compiler does not need to have a return type explicitly set as it can infer the return type. The error that you have encountered could have happened because of the following reasons:

The body does not have a return type

var body: some View…

View is one of the foundational blocks of SwiftUI. View in SwiftUI is a pure UI element moving out of the conventional mix of View and Controller in UIKit. In this blog, we will walk through the SwiftUI View and understand about it.

Why is View a struct and not a class anymore?

One of the fundamental principles of SwiftUI is to have a single source of truth in your code. A traditional UIKit approach of having a base UIView class and all other views inherit from it has a demerit wherein we have multiple stored properties in our view inherited from parent UIView. …

Protocols are one of the most important aspects of the Swift programming language. They consist of properties, methods, and other requirements that define the interface of any particular conforming type. Associated types are a great way to enhance the capabilities of protocols making them more generic and flexible.

Let us take a simple example of a protocol implementation:

Having your own business is what everyone dreams of. Every business has its own product specializations. So we maintain a product store for each business type that we have.

In the above code, we created a Business protocol that has…

Integrate Apple’s Combine into your view models

It’s been a while since Apple’s own reactive framework Combine came onto the scene. Being a RxSwift user for quite some time, I was more interested in Combine than Swift U, so I decided to learn it first.

I started migrating one of my UIKit + Swift + MVVM projects to Combine and MVVM to learn. This project creates an app named Nearby that displays some places around you (restaurants, ATMs, Cafes, etc). In this article, I’ll be sharing my experience of doing the migration, pain points, as well as sharing relevant resources with you.

For the scope of our…

Have you encountered the following in your code:

  • Your components are not that small and cute as they used to be while starting your development.
  • Components in your code produce undesired side effects that are hard to debug.
  • The components you write keep on becoming bulkier if multiple use cases and logics encountered.
  • Classes are becoming difficult to test might be due to their size or lack of separation of concerns.

If you have reeled with these then following principles of IOC will definitely be a lifesaver.

Table View and Collection View have been the pillars on which almost all iOS applications have been built. Building these collections is pretty easy and straight forward. The basic flow for populating any Table View or Collection View is:

The data source is generally the list of data that is supplied to the table view. The table views data source methods then iterate on this list and instantiate cells.

The datasource methods that take part in this:

The network layer with respect to a mobile application development could be summed as the combination of all the components that help you create, authenticate and trigger a request and process the response.

In this blog, I will share my experiences in building a network layer from my past projects. We will discuss the reasons behind the approaches involved.

How does an API connection look like?

The device sends a request and receives a response that is the data from the server after processing the request.

API Request

An API request typically consists the following components:

a) Request type

b) Request URL

Recently, a friend of mine asked me his queries on Concurrency and Parallelism. When I started explaining him his queries, we started discussing other related concepts and nomenclatures such as Threads -> Multi-threaded and Single, Asynchronous and Synchronous. At a point, we were confused with queries like:

How is concurrency related to parallelism?

What is synchronous and asynchronous execution?

What is the importance of synchronous and asynchronous programming in concurrency and parallelism?

How threads fit along with all these concepts?

Many of us sometimes get confused with such queries.

Hold on for a moment and try to answer the above…

G. Abhisek

Software Developer(iOS), Speaker & Writer at Swift India

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