Git Product home page Git Product logo

Comments (4)

jdewind avatar jdewind commented on July 22, 2024

Storyboards control the lifecycle of all objects and I don't think it is possible to hook into it. Controller's do not consistently call init internally either. Which means even if Objection were to overload init it wouldn't guarantee the controller was instantiated properly.

There are a number of callback methods you can use to fallback on (awakeFromNib for example) and use the default injector directly to inject your dependencies via the injectDependencies: method.

from objection.

fatuhoku avatar fatuhoku commented on July 22, 2024

Fair enough, but is it possible to have injectDependencies: inject THE Storyboard-created ViewController into Objection-instantiated objects? At present, if you try to do this with Objection, no ViewControllers are found in the object cache and therefore a second ViewController is created: not the behaviour we want!

i.e.
is there a way of obtaining a reference to the Storyboard-initialised ViewController in a JSObjectionModule definition such that we can call bind:toProtocol: or bind:toClass: onto it?

from objection.

fatuhoku avatar fatuhoku commented on July 22, 2024

Another way this could work is if Objection permits users to insert objects into the object cache, which then injectDependencies uses. Setting up the correct delegates is a very useful use case...

from objection.

jdewind avatar jdewind commented on July 22, 2024

injectDependencies: does not add to the injector context. It instead supplies the dependencies noted in objection_requires to the object passed into it.

If you want a reference to that view controller via Objection you could build a new injector with that view controller via a module using the said approach above.

Conversely, you could use a provider where the provider has hooks for adding the storyboard created VC to it.

from objection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.