Closed sharplet closed 8 years ago
I think something like this could work:
func viewDidLoad() {
super.viewDidLoad()
controller.configureTabs { child in
switch child {
case let feed as Feed:
// configure feed
return .configured
case let profile as Profile:
// configure profile
return .configured
default:
return .ignored
}
// or...
if let feed = child as? Feed {
// configure feed
return .configured
}
if let profile = child as? Profile {
// configure profile
return .configured
}
return .ignored
}
}
It would be nice to expose the functionality of
UIStoryboardSegue.destinationViewController(ofType:)
in a more general way that is useful in different contexts.For example, lets say you wanted to configure the tabs in a
UITabBarController
:For each tab, this code searches the view controller hierarchy until it finds a matching view controller, then continues to the next tab.
This would be more concise:
But has the disadvantage of searching each tab N times, where N is the number of different things you need to configure.
I think there should be a way to encapsulate the first search strategy using a higher-level construct.