Directly calling delegate's method in objective-c -
i created protocol requires class client implement method. in client class need perform same actions defined in method not when delegate calls it. don't think idea copy-paste code, don't know either if it's practice call method directly within client class. thinking maybe delegate methods should called delegate.
should create third method it's called inside delegate method , when need it? or, can call delegate method directly?
use blocks
instead of delegates
solve problem. blocks same work delegates, it's far cleaner, requires less plumbing work (think instance variables/properties gotta shuttle between classes , delegates.. in blocks, info encapsulated within block), , consistent direction ios/objective-c community moving in (you'll find lot of high profile libraries evolving substitute delegation , other stuff blocks).
if you're not familiar blocks or find it's quirky syntax annoying, here user friendly guide.
also here nice answer compares delegate
based solution block
based solution, , illustrates how block solution cleaner delegate one.
Comments
Post a Comment