ios - How do you pass data from one ViewController to the next with TyphoonStoryboard? -
i've got simplest possible application powered storyboard.
we've got uinavigationcontroller
, , view controllers , b.
a has textfield user supposed type name into. when user touches button, segues b, showing "hi, [name]!"
how pass user-entered name b typhoon?
with typhoon, presume lets me avoid using -prepareforsegue:sender:
, evil di perspective because requires coupling between otherwise totally unrelated view controllers. (e.g. viewcontrollerb.nametodisplay = self.textfield.text;
)
a nice feature of typhoon ability use assemblies factory interface mixes static , runtime dependencies, avoiding boilerplate of creating custom factory. feature called runtime arguments. since storyboards being used emit view controllers won't possible use:
- runtime arguments, storyboard interface has no concept of this.
- initializer injection, vcs emitted storyboard use
initwithcoder
something else can create mutable model object in assembly scope typhoonscopeweaksingleton
- (person *)storyboardmodel { return [typhoondefinition withclass:[person class] configuration:^(typhoondefinition *definition) { definition.scope = typhoonscopeweaksingleton; }]; }
you can inject top view controller, , subsequent children on stack. when stack popped, model object cleaned well.
since storyboard created view controllers work best property dependencies may use approach along typhoon's (still private, available on master) auto-wiring macros. saves time of creating assembly registration , wiring rules:
@interface infwelcomecontroller : uiviewcontroller <infwelcomeviewdelegate> @property (nonatomic, strong) injectedclass(person) model; @property (nonatomic, strong) injectedprotocol(webclient) client; @end
auto-wiring available integration test cases.
Comments
Post a Comment