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

Delegates - Cyclic dependencies #51

Open
ehrenmurdick opened this issue Mar 2, 2016 · 1 comment
Open

Delegates - Cyclic dependencies #51

ehrenmurdick opened this issue Mar 2, 2016 · 1 comment

Comments

@ehrenmurdick
Copy link

We're trying to set up a dependency graph which includes a delegate with a reference back up the graph. When we try to inject all the deps with Blindside we get an exception "Cyclic dependency found on key…".

How can we use BS to inject an object's delegate? The delegate has a weak reference to a protocol going back up the chain, so we'd expect it to be ok.

@briancroom
Copy link
Contributor

Hey @ehrenmurdick, I'm not so sure that Blindside is going to be able to help you very much with wiring up a delegate relationship like you're describing, although I'm not entirely sure without knowing more about what you're trying to achieve though.

Assuming you've working with the conventional Cocoa delegation pattern though, the reason you're running into trouble is that Blindside will try to instantiate a new object (and its transitive dependencies) whenever a dependency is requested, as opposed to populating the delegate field with s previously-instantiated object which is probably what you're hoping for. In these kinds of situations, the standard pattern is to hook up the delegate explicitly in code once the object graph has been set up.

If you have your heart set on having a framework help you out in this scenario, you may want to look into Typhoon which is powerful enough to handle this configuration.

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

No branches or pull requests

2 participants