Skip to content

fschmid311/InterfaceBacked

 
 

Repository files navigation

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.

About

Simplify usage of storyboard & nib files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 83.8%
  • Ruby 9.6%
  • Objective-C 6.6%