diff --git a/SwiftyExtensions/Swift+Extensions.swift b/SwiftyExtensions/Swift+Extensions.swift index 85bca67..4b90f08 100644 --- a/SwiftyExtensions/Swift+Extensions.swift +++ b/SwiftyExtensions/Swift+Extensions.swift @@ -17,12 +17,16 @@ public func Localized(key: String) -> String { } public func StringFromClass(object: AnyObject) -> String { - return NSStringFromClass(object.dynamicType).componentsSeparatedByString(".").last! + return NSStringFromClass(object.dynamicType).componentsSeparatedByString(".").last! as String } -public func LOG( _ body: AnyObject! = "", function: String = __FUNCTION__, line: Int = __LINE__) { - #if DEBUG - println("[\(function) : \(line)] \(body)") +public func StringFromType(type: T) -> String { + return String(type.self).componentsSeparatedByString(".").last! +} + +public func LOG(body: T, function: String = __FUNCTION__, line: Int = __LINE__) { + #if DEBUG || DEV + print("[\(function) : \(line)] \(body)", terminator: "\n") #endif } diff --git a/SwiftyExtensions/UIView+Addtions.swift b/SwiftyExtensions/UIView+Addtions.swift index b080462..10394cc 100644 --- a/SwiftyExtensions/UIView+Addtions.swift +++ b/SwiftyExtensions/UIView+Addtions.swift @@ -76,7 +76,7 @@ extension UIView { public func removeSublayers() { if let sublayers = self.layer.sublayers { - for layer in self.layer.sublayers { + for layer in sublayers { layer.removeFromSuperlayer() } } diff --git a/SwiftyExtensions/UIViewController+UIStoryBoard.swift b/SwiftyExtensions/UIViewController+UIStoryBoard.swift index d776d6e..0b8ea70 100644 --- a/SwiftyExtensions/UIViewController+UIStoryBoard.swift +++ b/SwiftyExtensions/UIViewController+UIStoryBoard.swift @@ -20,4 +20,17 @@ extension UIViewController { let storyboard = UIStoryboard(name: className, bundle: nil) return storyboard.instantiateViewControllerWithIdentifier(className) } +} + +extension UIViewController: StoryboardLoadable {} + +protocol StoryboardLoadable {} + +extension StoryboardLoadable { + + static func loadStoryboard() -> Self { + let className = StringFromType(Self) + let storyboard = UIStoryboard(name: className, bundle: nil) + return storyboard.instantiateViewControllerWithIdentifier(className) as! Self + } } \ No newline at end of file