Skip to content

1.x_Autowiring

Jasper Blues edited this page Apr 26, 2014 · 4 revisions

Block Assembly | Xml Assembly | Autowring | Using-assembled-components | Installing | Configuration-Management-&-Testing


In simple cases you may wish to use auto-wiring by type:

Shorthand Namespace

In your main prefix header file (or somewhere appropriate) add the following:

#define typhoon_shorthand 

This will allow 'autoWire' as a shorthand to 'typhoon_autoWire'.

Add the autoWire macro to your class

@implementation AutoWiringKnight
autoWire(@selector(quest), @selector(horse)) //Comma separated list of property names. 

//Main implementation body here

@end

#Now use your component

TyphoonComponentFactory* factory = [[TyphoonComponentFactory alloc] init];
Knight* knight = [factory componentForType:[Knight class]];

You can mix-and-match auto-wiring with other assembly styles:

TyphoonComponentFactory* factory = [TyphoonComponentFactory defaultFactory];
Knight* knight = [factory componentForType:[Knight class]];

##Autowiring Features

  • Auto-wiring will match by a single instance of the required class or protocol.
  • Adding the auto-wiring macro to a class will register that class with the container, if it is not already.
  • Auto-wiring is only available for property style injection (initializer not supported).
  • You can mix-and-match auto-wiring with other assembly types.

Quick Start!

Get started in two minutes.

Main Track

Get familiar with Typhoon.

Advanced Topics

Become a Typhoon expert.

Under the Hood

For contributors or curious folks.

Clone this wiki locally