Search code examples
iosobjective-cdependency-injectionioc-containertyphoon

Wiring objects with Dependency Injection and JSON in Objective-C Typhoon


I would like to define my objects in a JSON file, and then instantiate them using Typhoon. Is this currently possible with Typhoon? I've downloaded the code from github, and looked through the code and docs, but I don't see a way.

Thanks in advance!


Solution

  • Since Typhoon 2.0 we only support the native format (recommended) along with auto-wiring macros. The main benefits are:

    • IDE refactoring and code-completion works without any additional plugins
    • No "magic strings" when wiring by reference.
    • Components can be resolved using the assembly interface. Since version 2.0 this includes supplying runtime arguments along with static dependencies.

    In version 1.x, we supported XML along with the above styles, however it was not at all a popular feature. The main (valid) criticisms were that XML doesn't support the above benefits of the native style. This along with there being some overheads in maintenance lead us to decide to discontinue support in version 2.0.

    There was one benefit - the ability to define assemblies at runtime. The closest thing that we have at the moment is Typhoon Config, which allows defining configurations in a text file.

    Proceeding with JSON:

    It would be quite simple to define a JSON parser.

    Unless you have a strong reason for using JSON, we recommend the native style.