method argument wildcard - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: method argument wildcard (/thread-95.html)
method argument wildcard - Sumaleth - Apr 30, 2010 10:46 PM
I'd like to do something like this:
I use three different "resisterVertices" methods right now, but I'd like to have one method that can be used by all three vertex types.
If I was using NS objects I presume I could use id as the argument type, and then recast them in the switch statement, but this method sits in that area between the Objective-C and C parts of my project.
Is this possible, without wrapping them in some sort of NS object? I'm happy (even keen) to make it a C function if that helps.
method argument wildcard - Zorg - May 4, 2010 10:38 AM
Maybe you want to use void * ?
method argument wildcard - akb825 - May 4, 2010 09:08 PM
You can use a C++ template function to accomplish this. (http://www.cplusplus.com/doc/tutorial/templates/) You can compile C++ code with ObjectiveC by making that file's extension .mm instead of .m.
method argument wildcard - Sumaleth - May 5, 2010 07:59 AM
void* did the trick. I had tried it at one point, but didn't entirely understand how to use that pointer to access an array. This was the solution, with the void* argument:
Thanks for the help.
method argument wildcard - Zorg - May 5, 2010 08:16 AM
should also work by the way.