1

Inspired by idea of replacement delegates with block f.e like for UIAlertView

https://gist.github.com/puppybits/1523687

It is clear that delegates full-replacement impossible, but for such routine like UIAlertView where you need just one call-back handler imho that works fine.

I'm just wandering is there a way to have it dynamic and not related just to one class?

F.e BlockReplacement class is responsible for executing methods, receiving delegates and perform it in block.

something like this:

SomeObject *someObject = [[SomeObject alloc] init]; 
[BlockReplacement performSelector:@selector(doSomething:) 
                       ofObject:someObject 
                     blockHandler:doneBlock 
                forDelegateMethod:@selector(doneSomething:)];

there is a problem - someObject may has more then 1 delegate methods so then blockHandler: forDelegateMethod need to be something like varargs.

of course it's about runtime methods injection, does it sound like crazy, useless idea?

Injectios
  • 2,777
  • 1
  • 30
  • 50

0 Answers0