Latest 0.1.0
Homepage https://github.com/MediaHound/HNDCreatableViewController
License Apache
Platforms ios 7.0, requires ARC
Authors

[![CI Status](http://img.shields.io/travis/Dustin Bachrach/HNDCreatableViewController.svg?style=flat)](https://travis-ci.org/Dustin Bachrach/HNDCreatableViewController)
Version
License
Platform

What is HNDCreatableViewController

We often want to construct View Controllers that we designed in Storyboards. If you want to load these View Controllers, you need to tightly couple your code that creates the View Controller to know which Storyboard hosts the View Controller. Using HNDCreatableViewController, we store that information directly in the View Controller, so that other parts of our application can simply create a View Controller without having to know which Storyboard implements it.

Consider a MyAwesomeViewController, which is designed inside the Awesome.storyboard and has a View Controller Identifier of TotesAwesome.

We define our MyAwesomeViewController to conform to HNDCreatableViewController:

#import <HNDCreatableViewController/HNDCreatableViewController.h>

@interface MyAwesomeViewController : UIViewController <HNDCreatableViewController>

@end

We then implement MyAwesomeViewController and define its Storyboard and View Controller Identifier:

#import <AtSugar/AtSugar.h>
#import <AtSugarMixin/ASMixin.h>

@implementation MyAwesomeViewController

@mixin (MyAwesomeViewController, HNDCreatableViewControllerMixin)

@declare_class_property (viewControllerStoryboard, @"Awesome")
@declare_class_property (viewControllerIdentifier, @"TotesAwesome")

@end

We used AtSugar and AtSugarMixin to make the implementation short and to the point.

That’s it. Now if you want to create a MyAwesomeViewController from somewhere else in your code, you can just do:

MyAwesomeViewController* vc = [MyAwesomeViewController create];
[self presentViewController:vc animated:YES completion:nil];

Installation

HNDCreatableViewController is available through CocoaPods. To install
it, simply add the following lines to your Podfile. Note: we recommend using AtSugar and AtSugarMixin, so add it to your Podfile as well.

pod "HNDCreatableViewController"
pod "AtSugar"
pod "AtSugarMixin"

Author

Dustin Bachrach, [email protected]

License

HNDCreatableViewController is available under the Apache License 2.0. See the LICENSE file for more info.

Latest podspec

{
    "name": "HNDCreatableViewController",
    "version": "0.1.0",
    "summary": "Creatable view controllers",
    "homepage": "https://github.com/MediaHound/HNDCreatableViewController",
    "license": "Apache",
    "authors": {
        "Dustin Bachrach": "[email protected]"
    },
    "source": {
        "git": "https://github.com/MediaHound/HNDCreatableViewController.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Classes/**/*.{h,m}"
}

Pin It on Pinterest

Share This