Last active
August 29, 2015 14:21
-
-
Save Cananito/f06987c90d05979f206a to your computer and use it in GitHub Desktop.
Protocol Property Subclassing.
This file contains 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 characters
import UIKit | |
class ViewA: UIView { | |
} | |
class ViewB: UIView { | |
} | |
protocol ViewController: class { | |
typealias View: UIView | |
var view: View { get } | |
} | |
class ViewControllerA: ViewController { | |
var view: ViewA { | |
get { | |
return ViewA() | |
} | |
} | |
} | |
class ViewControllerB: ViewController { | |
var view: ViewB { | |
get { | |
return ViewB() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What I originally intended: