You are viewing...

NSInvocation's Equivalent in Java?

Updated on November 14, 2012 at the 00th hour
Posted under:

DISCLAIMER: Expressed views on this blog are my own.

Looks like browsing a discussion on LinkedIn about differences between Java and Scala turned out something I never knew about: Method Handles. If you remember my post on how freaking useful NSInvocations are, well read it!

Basically, let's say you want to execute a method on a function somewhere far far away without knowing what object you are talking to, you use a Method Handle in Java or a NSInvocation to encapsulate the method. My use case scenario was in the iPhone app I created during the summer. I used NSInvocation to execute actions. I don't remember the exact case, but I think the pinview had success and fail actions and I needed a way to do it (I was thinking of using functions pointers). Long story short, I found NSInvocation while reading StackOverflow and curiously reading the iOS Documentation, which is well written (I'm not sure which came first). Whenever the idea of success/fail action comes up I use a pattern I deem the Action Pattern which basically uses NSInvocation, but now I can use Method Handles, so it will always be an option.
You just read "NSInvocation's Equivalent in Java?". Please share if you liked it!
You can read more recent posts here.