Last active
October 20, 2015 16:48
-
-
Save morizotter/16d46f263b9b80f9331a to your computer and use it in GitHub Desktop.
StoryboardやXibファイルからインスタンスを生成するprotocol ref: http://qiita.com/morizotter/items/f25bf03fa4e151703451
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol InstantiateFromNibable { | |
typealias Instance | |
static func instantiateFromNib() -> Instance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class LoadingFooterView: UIView, InstantiateFromNibable { | |
static func instantiateFromNib() -> LoadingFooterView { | |
return UINib(nibName: "LoadingFooterView", bundle: nil).instantiateWithOwner(nil, options: nil).first as! LoadingFooterView | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let footerView = LoadingFooterView.instantiateFromNib() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SearchViewController: UIViewController, InstantiateFromNibable { | |
static func instantiateFromNib() -> SearchViewController { | |
return UIStoryboard(name: "Search", bundle: nil).instantiateViewControllerWithIdentifier("SearchViewController") as! SearchViewController | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let vc = SearchViewController.instantiateFromNib() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment