The project covers dynamic tableview cell height, MVVM and clean Architecture and Prefetching Table Data From server or infinite scroll view

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 : –

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 : –


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 : –

JSON Decoder with Models

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

Projects Snipet : –

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 : –


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 : –

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

Projects Snipet : –

Technologies

Project is created with:

  • Xcode : 13.1
  • IOS version: 15

Application GIF

RPReplay_Final1641881731.mov


GitHub

View Github