From c673b3ca4536bf60bd5a7f74613073b89ef0ed29 Mon Sep 17 00:00:00 2001 From: corin8823 Date: Tue, 10 Nov 2015 08:31:49 +0900 Subject: [PATCH] Add NibLoadable for UIView --- SwiftyExtensions/UIView+Addtions.swift | 17 ++++++++++++----- .../UIViewController+UIStoryBoard.swift | 14 -------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/SwiftyExtensions/UIView+Addtions.swift b/SwiftyExtensions/UIView+Addtions.swift index 10394cc..cab60c0 100644 --- a/SwiftyExtensions/UIView+Addtions.swift +++ b/SwiftyExtensions/UIView+Addtions.swift @@ -51,11 +51,6 @@ extension UIView { self.frame.origin.y = y } - public class func loadNib() -> UIView { - let name = StringFromClass(self) - return NSBundle.mainBundle().loadNibNamed(name, owner: nil, options: nil)[0] as! UIView - } - public func roundedCorrner(radius: CGFloat) { self.layer.cornerRadius = radius self.clipsToBounds = true @@ -91,3 +86,15 @@ extension UIView { return false } } + +extension UIView: NibLoadable {} + +protocol NibLoadable{} + +extension NibLoadable { + + static func loadNib() -> Self { + let className = StringFromType(Self) + return NSBundle.mainBundle().loadNibNamed(className, owner: nil, options: nil)[0] as! Self + } +} \ No newline at end of file diff --git a/SwiftyExtensions/UIViewController+UIStoryBoard.swift b/SwiftyExtensions/UIViewController+UIStoryBoard.swift index 0b8ea70..7e1e6db 100644 --- a/SwiftyExtensions/UIViewController+UIStoryBoard.swift +++ b/SwiftyExtensions/UIViewController+UIStoryBoard.swift @@ -8,20 +8,6 @@ import UIKit -extension UIViewController { - - public class func initialLoadStoryboard() -> UIViewController { - let storyboard = UIStoryboard(name: StringFromClass(self), bundle: nil) - return storyboard.instantiateInitialViewController()! - } - - public class func loadStoryboard() -> UIViewController { - let className = StringFromClass(self) - let storyboard = UIStoryboard(name: className, bundle: nil) - return storyboard.instantiateViewControllerWithIdentifier(className) - } -} - extension UIViewController: StoryboardLoadable {} protocol StoryboardLoadable {}