Replacement for Objective-C "lazy-getter-as-dependency-injection" pattern in Swift? -


short of typhoon, told way (or @ least simulate) dependency injection in objective-c lazy-getter pattern:

- (foo)foo {     if (!_foo) {         _foo = [foo sharedinstance];     }     return _foo; } 

i detested this, ended multiple instances of seven-line chunk of boilerplate code polluting each view controller. couldn't hide in category since can't define properties on category.

until swift gets annotations , introspection features , can write like:

@injected foo: foo! 

... patterns people using in swift obtain reference shared model objects multiple storyboard-instantiated view controllers?


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -