Skip to content

Commit

Permalink
:Appdelegate window stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Esqarrouth authored and Goktug Yilmaz committed Nov 14, 2015
1 parent 4ed7d62 commit 3414281
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion EZSwiftExtensions.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "EZSwiftExtensions"
s.version = "0.3"
s.version = "0.5"
s.summary = ":smirk: How Swift standard types and classes were supposed to work"
s.description = ":smirk: How Swift standard types and classes were supposed to work."
s.homepage = "https://github.com/goktugyil/EZSwiftExtensions"
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ print(appBuild) // 7
print(appVersionAndBuild) // v0.3(7)
```

Easily access your appDelegate instance:
Easily access your appDelegate instance and your window:

``` swift
let myAppDel = appDelegateVariable
myAppDel.window!.rootViewController = UIViewController()
// OR
let myAppDelegateWindow = appDelegateWindow
myAppDelegateWindow.rootViewController = UIViewController()
```

Easily access your ViewController on top of your view stack:
Expand Down
11 changes: 8 additions & 3 deletions Sources/EZSwiftExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ public var appVersionAndBuild: String {
}

/// EZSwiftExtensions - Your normal appDelegate
public var appDelegateVariable: UIResponder {
return UIApplication.sharedApplication().delegate as! UIResponder
public var appDelegateVariable: UIApplicationDelegate {
return UIApplication.sharedApplication().delegate!
}

/// EZSwiftExtensions
public var appDelegateWindow: UIWindow {
return UIApplication.sharedApplication().keyWindow!
}

/// EZSwiftExtensions - Gives you the VC on top so you can easily push your popups
public var topMostVC: UIViewController {
var topController = (UIApplication.sharedApplication().keyWindow!.rootViewController)!
var topController = appDelegateWindow.rootViewController!

while let presentedVC = topController.presentedViewController {
topController = presentedVC
Expand Down

0 comments on commit 3414281

Please sign in to comment.