Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.34 KB

Readme.md

File metadata and controls

45 lines (29 loc) · 1.34 KB

Interface Backed

Carthage compatible

Original idea and implementation by Benjamin Sandofsky's gist

I just simplified the code a bit and put it in a Framework. Added a similar approach for UIView subclasses that rely on a .nib file.

Released under the MIT license

Usage

Your classes must be declared final to adopt the protocol.

UIViewController

final class ViewController: UIViewController, StoryboardBacked {}

let vc = ViewController.newFromStoryboard()

You can use a custom name or a custom bundle. The function defaults to a storyboard named as the view controller and to the bundle the class is in. So this works even when your view controller class in inside a framework and not the main bundle.

Hint: Double check that you made your custom view controller the initial view controller for the storyboard.

UITableViewCell

final class Cell: UITableViewCell, NibBackedCell {}

tableView.registerNib(Cell.cellNib(), forCellReuseIdentifier: Cell.identifier())

Hint: Double check the identifier for the cell in the .nib file. It must reflect the name of the class.

For more information check the included Example target.