Popularity
0.3
Declining
Activity
0.0
Stable
5
1
1

Programming language: Swift
License: MIT License
Latest version: v1.4.0

StoryboardBuilder alternatives and similar libraries

Based on the "Dependency Injection" category.
Alternatively, view StoryboardBuilder alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of StoryboardBuilder or a related project?

Add another 'Dependency Injection' Library

README

StoryboardBuilder

Simple dependency injection for generating views from storyboard.

Carthage Compatible Swift 4.2

Description

StoryboardBuilder is framework to help simply and easily generating that View and ViewController are defineded in Storyboard and Xib. You can generate instance and parse type of one by using StoryboardBuilderProtocol and XibBuilderProtocol description.

Install

Carthage

Add following.

github "hiro-nagami/StoryboardBuilder"

How ot use

Way to get Storyboard Class

  1. Create storyboard file in your project.
  1. Import StoryboardBuilder_iOS.
  2. Your custom view controller extends StoryboardBuilderProtocol.
  3. storyboardName and storyboardID are implemented in that view controller.
import UIKit
import Foundation
import StoryboardBuilder_iOS

class CustomViewController: UIViewController, StoryboardBuilderProtocol {
    static var storyboardName: String = "Main"
    static var storyboardID: String = "CustomViewController"
    ...
}

You can use such as following.

/* You can generate CustomViewController just like following.
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let customeVC = storyboard.instantiateViewController(withIdentifier: "CustomViewController") as! CustomViewController
**/

let customViewController = CustomViewController.getModule()

Way to get Xib Class

  1. Create xib file in your project.
  1. Import StoryboardBuilder_iOS.
  2. Your custom view controller extends XibBuilderProtocol.
  3. xibNameis implemented in that view controller.
import UIKit
import Foundation
import StoryboardBuilder_iOS

class CustomView: UIView, XibBuilderProtocol {
    static var xibName: String = "CustomView"
    ...
}

You can use such as following.

/* You can generate CustomView just like following.
   let identifier = "CustomView"
   let customViewNib = UINib(nibName: identifier, bundle: nil)
   let customView = customViewNib.instantiate(withOwner: self, options: nil).first as! CustomView
**/

let customView: CustomView = CustomView.getModule()

You can register and use CustomTableViewCell.

class CustomViewCell: UITableViewCell, XibBuilderProtocol {
    static var xibName: String = "CustomView"
    ...
}

class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.sb.register(cellClass: CustomViewCell.self)
        self.tableView.sb.register(cellClasses: [
            CustomViewACell.self,
            CustomViewBCell.self,
            CustomViewCCell.self,
        ])
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.sb.dequeueReusableCell(cellClass: CustomViewBCell.self)

        ...

        return cell
    }
}

License

StoryboardBuilder is released under the MIT license. See LICENSE for details.

Author

@hiro_nagami


*Note that all licence references and agreements mentioned in the StoryboardBuilder README section above are relevant to that project's source code only.