Latest 1.0.1
Homepage https://github.com/inloop/UIViewController-DisplayChild
License MIT
Platforms ios 10.0
Authors

CI Status
License
Version
Platform
Carthage Compatible

The problem: sometimes you need to embed a controller, but it might be embedded already. E.g. you have an empty view, and you do refresh only to get empty view again. If you do not check for its existence, you might end up creating a new instance unneccessarily. This can also have bad side effects when there is some heavier work in viewDidLoad for example.

The solution: transition to type, instead of an instance. If the instance does not exist, it is created for you and you have a possibility to configure it after initialization via configuration closure. If the instance does exist, only the configuration closure is performed so that you can display a new content. You do not have to worry anymore whether the controller you intent to embed is already presented.

Example:

import UIViewController_DisplayChild

displayChild(
  ofType: ErrorViewController.self,
  in: containerView,
  animated: false,
  configuration: { controller in
      controller.model = model
  }
)

Latest podspec

{
    "name": "UIViewController-DisplayChild",
    "version": "1.0.1",
    "summary": "UIViewController containment made easy",
    "description": "The problem: sometimes you need to embed a controller, but it might be embedded already. E.g. you have an empty view, and you do refresh only to get empty view again. If you do not check for its existence, you might end up creating a new instance unneccessarily. This can also have bad side effects when there is some heavier work in viewDidLoad for example.nnThe solution: transition to type, instead of an instance. If the instance does not exist, it is created for you and you have a possibility to configure it after initialization via configuration closure. If the instance does exist, only the configuration closure is performed so that you can display a new content. You do not have to worry anymore whether the controller you intent to embed is already presented.",
    "homepage": "https://github.com/inloop/UIViewController-DisplayChild",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "INLOOPX": "[email protected]"
    },
    "source": {
        "git": "https://github.com/inloop/UIViewController-DisplayChild.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.1",
    "source_files": "UIViewController-DisplayChild/**/*"
}

Pin It on Pinterest

Share This