Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject dependencies into storyboard views that have a typhoonKey #350

Merged
merged 1 commit into from
May 27, 2015
Merged

Conversation

chazmuzz
Copy link

My usecase for this was a large UIView subclass with some distinct pieces of logic. I felt that it was violating SRP, so I extracted the logic into a couple of classes. I needed some way to inject the new class dependencies into the UIView subclass.

@alexgarbarev
Copy link
Contributor

I see. That looks ok. But I think same functionality can be done via TyphoonLoadedView. Have you tried (looked into) that?

With TyphoonLoadedView you place UIView inside storyboard or xib, set class to TyphoonLoadedView and set restorationIdentifier just like typhoonKey (because restorationIdentifier set at init time).
That way has advantage: your view would be created from assembly (and then replaced in storyboard), using your definition and can be loaded from external xib. I use that to reused xib based views in the storyboard.

Your solution with typhoonKey is great, but it's only injects properties and method - no way to change instantiation..
Options: merge both solutions into one, keep both as is..

@jasperblues
Copy link
Member

TyphoonLoadedView is still a well-kept secret (no docs) so I would be surprised if many folks are using it.

Let's keep the solutions separate:

  • This is a logical extension of Typhoon's storyboard integration, so a user could reasonably guess this behavior. Its consistent with the rule that any objects not instantiate by Typhoon only support property and method injection. (AppDelegate, Storyboard Controllers).
  • TyphoonLoadedView has its own special constraints. Wiring connections requires that a view be backed be a protocol to confer any sense of type beyond id.

Let's change the documentation section 'Storyboad Integration' to be 'UIKit Integration' and document all three features.

jasperblues added a commit that referenced this pull request May 27, 2015
Inject dependencies into storyboard views that have a typhoonKey
@jasperblues jasperblues merged commit 81db968 into appsquickly:master May 27, 2015
@jasperblues
Copy link
Member

Merged to master. The are a couple of areas where we want to make the behavior consistent with the rest of Typhoon, so there will be some minor changes before we tag document and tag a new version.

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.

3 participants