Skip to content

kiranSDM/MVVM_Architecture_iOS

 
 

Repository files navigation

smartData: Scaling Expectations in Swift

iOSArchitecture_MVVM

This repository contains a sample app that implements MVVM architecture with Swift 4.2 t kick start iOS project at smart Data.

Architecture Defines Targets for:

    - iOSArchitecture_MVVM
    - iOSArchitecture_MVVMTests
    - iOSArchitecture_MVVMUITests

To focus upon the main target i.e. iOSArchitecture_MVVM and to kick start we offer basic functionality of UserLogin which exists in approximately all the applications.

Folder Structure :

Architecture is following MVVM pattern using Swift Language with version 4.2 and folder structure defined for this is:

Controllers:

That contains all the controllers that manages context between ModalView & View. To kick start controllers contained in folder
        - BaseViewControler -> Base of every controller inherited from UIViewController. It is required so that if any change is required in all the screens of application then code for that can be written in base so impelementation can be done around the app.
        - LoginViewController -> Login View that is defined first and is the landing page when application opens. It is inherited from BaseViewController.
        - HomeViewController -> After Login where user lands is Home and it is also inherited from BaseViewController.

Models :

All the modals and information in modal form can be saved in modal classes will be defined here. Currently contains:
        - User -> This is example of modal that is created after user login to modal the user information.
        - Listing -> This is example of modal that is created to display listing in HomeViewController.

Views :

All the custom views that are required in app shall come under this. It doesnot contain any file but contributes to the architecture.

Libraries:

Any external libraries that work as plug and play or libraries that does not contribute to Pods or Carthage shall come under this folder. Currently does not contain anything.

Applications :

AppDelegate class is singleton class defining application instance and window of application. This folder contains AppDelegate and Bridging Header.
        - AppDelegate -> Defining window and application instance.

Network :

Contains the classes that communicates with external servers using the network and all network related information: Currently contains:
        - APIService -> Contains all methods for hitting and external API for server communication. 
        - UserService -> Example how to hit API for login and essential for KickStart.

Helpers:

Any class that does not belong to Controller, Modal or View but is helpful to ease the code and save redundancy shall come under this folder. Example for this is color schemes classes of app, AppContants, UserDefaults, Shared Singeltons, StringsContants, Identifiers. Currently contains:
        - Constant -> Contributes to Configurations and Identifiers as example. 
        - ApiConstant -> Contributes to all keys and url related to server communication

Stores:

Store the data in application. Contains:
        - AppInstance -> Stores the data for application lifecycle so that the information that is required during application lifecycle can directly be fetched from here.

Extensions :

Extensions are that helps to develop custom methods that are very frequently used in the applications like String Modifications, Alerts, Bundles. Contains:
        - String+Extension -> Methods to modify string like clipping, range, shift, email validation, phonenumber validation etc.
        - UIAlertController -> To show alerts in application.     
        - UIApplication -> Extension of our application instance.
        - Bundle -> Information of our application like version number, identifier, build number.
        - UICOlor+Hex -> To generate UIColor instance from HEX value.

Main.storyboard :

Storyboard is used to draw UI for viewcontrollers.

Below are points which are handled within this sample app.

  1. Basic flow to handle app navigation
  2. Communicate with web server using REST api
  3. NSURLSession to call web services
  4. Codable protocol to parse JSON response and generate model class with help of Generics

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 99.2%
  • Ruby 0.8%