Add empty ASViewController initializer to facilitate subclassing #1754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Take 2 of #1740 because I'm an idiot]
Per Slack discussion with @nguyenhuy.
If you want to use
ASViewController
throughout your app as a generalizedUIViewController
stand in (as the docs mention) it's tricky (at least in Swift) when you want to take a non-node based normalUIViewController
and make it inherit fromASViewController
(again to perhaps have a consistent root subclass) because there's only one designated initializer inASViewController
,init(node:)
which does not accept nil values despite the docs indicating that should be okay.Currently the only course of action is to pass in a dummy node (e.g.:
ASViewController(node: ASDisplayNode())
). Other courses of action include unmarkinginit(node:)
as the designated initializer or letting it accept nil values, but neither of those are optimal, per @nguyhuy:A proposed solution would be to introduce a second designated "empty" initializer that would just use the underlying
UIViewController
, makenode
nil, and facilitate subclassing, which is what I did in this PR.Other context: