1

I'm, trying to emulate a Double Dispatch in Objective-C.

I know Objective-C does not support function/method overloading. But can you emulate this?

Any idea.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Josué H.
  • 1,171
  • 3
  • 15
  • 35
  • https://stackoverflow.com/questions/19882396/double-dispatch-for-collision-handling-with-spritekit – matt May 28 '18 at 19:28

2 Answers2

1

You can do it as in C++/C# with 2 single dispatches (aka "visitor" pattern, see https://en.wikipedia.org/wiki/Double_dispatch#Double_dispatch_in_C++ ).

Or you can do it manually with some runtime type checking on the argument (see isMemberOfClass).

battlmonstr
  • 5,841
  • 1
  • 23
  • 33
0

In this repo give an example of how to Implement Double Dispatch in Objective-C

Josué H.
  • 1,171
  • 3
  • 15
  • 35
  • 1
    This is a link only answer. It would nice that you give a summary of how it works, so that the readers don't have to go all the files in the repo to find out. – Christophe Sep 30 '18 at 22:02