-
-
Save davidandreoletti/1827c0f99b053e53e45d42690cf79442 to your computer and use it in GitHub Desktop.
Revisions
-
Vincent Wayne created this gist
Aug 26, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ public protocol DataSource: class { associatedtype AbstractType func source() -> AbstractType } class ViewController<T: DataSource>: UIViewController { weak var dataSouce: T? typealias AbstractType = T.AbstractType override func viewDidLoad() { super.viewDidLoad() let source: AbstractType? = dataSouce?.source() print("Source: ", source) } } @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, DataSource { var vc: ViewController<AppDelegate>? var window: UIWindow? typealias AbstractType = Date func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. vc = ViewController<AppDelegate>() vc?.dataSouce = self window = UIWindow(frame: UIScreen.main.bounds) window?.rootViewController = vc window?.makeKeyAndVisible() return true } // MARK: - DataSource func source() -> AbstractType { return Date() } }