Skip to content

Commit

Permalink
Add loadStoryboard and Fix misc
Browse files Browse the repository at this point in the history
  • Loading branch information
corin8823 committed Oct 5, 2015
1 parent fa432e1 commit 5868d9f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 8 additions & 4 deletions SwiftyExtensions/Swift+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(type: T) -> String {
return String(type.self).componentsSeparatedByString(".").last!
}

public func LOG<T>(body: T, function: String = __FUNCTION__, line: Int = __LINE__) {
#if DEBUG || DEV
print("[\(function) : \(line)] \(body)", terminator: "\n")
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion SwiftyExtensions/UIView+Addtions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
13 changes: 13 additions & 0 deletions SwiftyExtensions/UIViewController+UIStoryBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 5868d9f

Please sign in to comment.