This article contains complete flow of handling Documents from picking to previewing with SwiftUI. This is kind of code along. The flow is as follows:

  • Pick Documents from Files
  • Adding Documents to Local
  • Adding Documents to iCloud
  • Integrating Document Handlers with ViewModel
  • Preview Documents
  • SwiftUI Views
  • Demo

Pick Documents from Files

Files such as text, word and csv can be picked using ‘UIDocumentPickerViewController’ of UIKit. The same can be used with SwiftUI using UIViewControllerRepresentable bridge.

UIViewControllerRepresentable is used to bridge UIKit and SwiftUI.

UIDocumentPickerViewController is created by specifying file types supported.

‘didPickDocumentsAt’ of DocumentPickerCoordinator will be called after user selects documents with list…

The popularity of SwiftUI is increasing every day. It is good to have that in our iOS development stack.

This article is to build one of common features we come across in many popular iOS Apps like WhatsApp. The feature is when we tap on same selected tab from tab bar, If we are not on top of that selected tab then we will be moved to top.

Let’s build this popular feature in SwiftUI. Also this can be easily customised to moving anywhere in selected tab with just a click.


We will use a simple view which we will…

In this article, We will make a Widget for an iOS Application. To start with, We need to answer ourself few questions:

  1. What information we are going to display in Widget ?
  2. How frequently we need to update the data in widget ?
  3. Is our widget configurable by user ?

Once you are ready with answers, Start making one with below steps. Even if you are not sure of above questions, Start right away. You can answer by end of this article.

Add new Target to your project

Like any other extensions, Widget is also an extension to our application. …

Identity of View plays important rule in managing SwiftUI Views lifecycle. Each View has its own identity. It can be explicitly given or taken from structural placement .

In UIKit/APPKit, each view has pointer identity since they are reference types.

WWDC is a favourite week for iOS Developers which brings huge advancements to APIs used by them in regular life. Apple also released beta versions of iOS, iPadOS, watchOS, tvOS and MacOS

But the advancements is for a year not just for one week. The sessions came online this week. That doesn't mean we have to be confident on all advancements. Anyhow, there is good time to upgrade your app with these advancements.

Plan Of Action

It is not bad having some plan or schedule.

Swift Concurrency

Before WWDC I re-visited all the basics and especially Dispatch Queues, closures and Combine. Concurrency in swift got…

When your app has some unique file to handle and you feel creating custom file extension or adding the custom file extension created by another developer that suits your needs then follow this article to make it possible.

Before going straight away to the procedure/steps, let us understand the Uniform Type Identifiers in iOS development.

Uniform Type Identifiers

Uniform Type Identifiers carries identity of your documents or files across the system. UTI tells system what apps can handle that particular document. For example when you try to open image, you can see various supported applications under ‘Open With’ in finder.

In the same…

Unlike many other languages, Enums in swift are very powerful. But we usually limit the usage of enums for few spots such as custom error type and representing different states of object.

Enums is basic value type used very commonly in iOS development. In this article, we will use enums in some uncommon but plausible use cases.

Overloading Cases

Associated values are biggest asset of enums. It is good to keep in mind that we can overload the cases by varying associated values. Here is simple example:

enum Role {  case artist  case developer  case director  case custom(String)  case custom(name: String)}

Test Equality

Swift has large number of functions that can be readily used in iOS development. contains() and filter () in swift are useful when we need to search if a number exists in list and filter list based on a condition respectively.

In some scenarios these functions cannot be used as such. One such scenario is searching strings(functionality of search in contacts). Searching in contacts takes keyword/keywords and searches for them in every contact first name or last name i.e., search where order doesn’t matter.

We will extend Array to use contains and filter in searching and filtering an array where…

Strings in swift are very commonly used by iOS Developers. We solve variety of problems in our development with the power of strings. But we generally overlook some of important functions in strings. In this article I try to collect such functions and add some extensions possibly.

Separate substrings from string

In development we come across reading csv files and separating tags entered by user. In these scenarios we need to create an array of strings from a string separated by some separator. ‘components’ function in swift can be used here.

let res = str.components(separatedBy: ",")

output is array of strings which are separated…

Before writing the custom functions, let us re-visit the available inbuilt functions which are comparatively less used but powerful.

Range Operator As Index

we can use open range or closed range operator to access and modify elements inside array. If the array can't accommodate change then it will throw error.

var array = [1,2,3]array[0…1] = [2,2]
print(array[0..4]) // error: Index Out Of Range


enumerated() will return a pair which has index and element in each iteration.

array.enumerated().forEach({print(“\($0) -> \($1)”)})


Compare each and every element inside two arrays based on index and return true only if all elements at respective indexes are equal. …

Sai Durga Mahesh

Love playing with data

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