Another simple but yet complex app on all iOS devices is the Contacts app, made by Apple, Inc. By contrast, learning how to build or clone the Contacts app will give you an in-depth knowledge of the Swift language, Core Data and Xcode.

The Contacts app is jam-packed with information to start you off as an aspiring iOS developer. These are the few things I've noticed that makes up the Contacts app:

  • Image uploading
  • Data storage - Core Data
  • UITableViewController
  • UITableViewController - UISearchResultsUpdating
  • UITableViewController - Custom Cells

With this information, I came up with something very basic, not perfect, that saves data using Realm 🤓

mayneweb-contacts-1

What has led you to build a Contacts app?

I'm building a side project for the iPhone 5 and up. It's an app that lets freelancers record their work done and bill their clients for completed work. It takes the model of an accounting app but generally it's not. The app can:

  • Record expenses
  • Generate invoices
  • See profits after all taxes
  • View profits, expenses and highlights per tax year (UK only)
  • See which clients brings in the most work

I live in the UK so the idea was to design for the UK market but keep in mind the expansion for the rest of the world. Here's the HomeViewController I did in Adobe XD:

Making the contacts app

By building this side project, I was then introduced to the Contacts app. Eventually, I will change the looks of how I've designed the Contacts app; I was intrigued to build it like for like, to learn how Apple did it. I've also watched many tutorials on learning UITableView but none came even close of explaining the complexity of the Contacts app. What I've done is not perfect; I'm using this knowledge as my first stepping stone into iOS development.

What have you learnt making the Contacts app?

There are so many things, really; extensions, structs, custom cells, passing data to and from controllers, basic animations, permissions, auto layouts, CALayers, graphs, non use of a storyboards, heavy use of protocols, Realm, and others I'll get into with the continuation of this blog post – Part 2.

Why using Realm?

I was watching a youtube video about using Core Data and it turns out that I needed to store objects using a relationships. If I'm correct, Core Data is not meant for relational objects. No? I'm experienced with PostgreSQL and used to having one-to-many, many-to-many, etc schemas thus decided to go with Realm as Realm fits my design model perfectly. Before Realm, I was making api calls to an external server that I've created to store data. This includes setting up user authentication 😰. This process seems wrong so I searched the web and found Realm. No need to make any api calls, simply store data on the user's device.

Design first

Since no storyboard was involved with this project, I rely heavily on my designs, either done in Sketch or Adobe XD while encapsulating my love for a pixel perfect design. For example this bit of code:

let iconView: UIImageView = {
    let imageView = UIImageView()
    imageView.frame = CGRect(x: 0, y: 0, width: 138, height: 142)
    imageView.image = UIImage(named: "tax_year_cal")
    imageView.contentMode = .scaleAspectFill
    imageView.clipsToBounds = false
    return imageView
}()

// Setting up views
view.addSubview(iconView)

// Constraints
iconView.anchor(view.topAnchor, topConstant: 61.30, widthConstant: iconView.frame.width, heightConstant: iconView.frame.height)
iconView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

width, height and all constants have to be the correct numbers else my application will never be as in design. My aim is to have my app looks as in design by 99.98%; 100% would be a bonus. I do have on few views where my app is 100% like the design.

In part 2, I look forward to show exactly how I've built this Contacts app, the current stage it's in and I'll demonstrate the iteration process of the final application (the Client section). If there's a possibility that the client section of this side project could be a standalone app, I'll separate it and have it in the App Store.