Quinbay

The Quinbay is a sample application. The project covers dynamic tableview cell height, MVVM and clean Architecture and Prefetching Table Data From server or infinite scroll view.

Things to learn

MVVM and Clean Architecture

The project’s architecture uses MVVM architecture. Here “ViewController” is responsible for updating the API and passing the user touch request to View models.

Projects Snipet : –

Screenshot 2022-01-11 at 12 01 41 PM

The view model is initiated with SearchAPIHandler Protocol. Here SOLID Principle’s Open Close principle is used. Any class can make SearchAPI Handler provided some protocol rules.

Projects Snipet : –

Screenshot 2022-01-11 at 12 08 22 PM
Screenshot 2022-01-11 at 12 10 04 PM

Dynamic cell height

The tableview cell uses dynamic cell height. The technique to use dynamic cell height is to add constrains from top to bottom and make the table view height dynamic. Other important things is to give don’t give height to labels as it can expand and make its number of lines 0 or custom as per requirement.

Projects Snipet : –

Screenshot 2022-01-11 at 12 02 04 PM

JSON Decoder with Models

JSON received from server is mapped to model classes using Codable Protocol and JSONDecoder class.

Projects Snipet : –
Screenshot 2022-01-11 at 12 02 28 PM

Prefetch table data from server

When user reaches the bottom of the page, in “prefetchRowsAt” function, we inform view model to fetch more products with “page” incremented.

Projects Snipet : –

Screenshot 2022-01-11 at 12 13 13 PM
Screenshot 2022-01-11 at 12 14 24 PM

Infinite scrollview

See the attached GIF. As soon as user reaches bottom of the page, view model fetches data and append to current product list and show.

Canceling Previous Search Call when new call added in Queue.

In the current session, all the tasks are fetched and mached to given search string. If matches and the next request occured, the last all tasks are cancelled.

Projects Snipet : –

Screenshot 2022-01-11 at 12 15 23 PM

When task is cancelled, callback is received with -999 error code. Here return and don’t do anything.

Projects Snipet : –

Screenshot 2022-01-11 at 12 16 26 PM

Technologies

Project is created with:

  • Xcode : 13.1
  • IOS version: 15

Application GIF

RPReplay_Final1641881731.mov


GitHub

View Github