Skip to content

Conversation

@fabfelici
Copy link

Hello! This PR changes ViewControllerLifecycle implementation to a swizzling based approach because I noticed some issues with the existing child view controller approach:

  • If you have a UINavigationController and you start observing the events on it, the rootViewController of the navigation controller will be swapped with a WrapperViewController resulting in an empty view. TabBarController is potentially open to same type of issue.
  • If you are implementing a container view controller and need to also observe its lifecycle via reactive the children array could become hard to manage.
  • Some crash detection libraries inspects the view hierarchy when a crash happens and if there is a view controller containing the WrapperViewController as child, the stack trace messages become hard to understand because of these WrapperViewController noise.

I don't like that this solution is based on swizzling but I believe there's no easy way to address this without creating a base UIViewController subclass that all the other VCs have to subclass.
This piece of code was also untested and I added some tests on top of it now, let me know if you see any issue!

cc @ibrahimkteish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant