I want to minimize the amount of Obj-C code in my project.
As part of this effort it becomes necessary to abstract the multitouch UITouch data, to instantiate some C++ classes that will manage hold the data as I work on it from C++, rather than working with it directly via objective C. There are many reasons for doing it this way (such as being able to hook into the code using any arbitrary form of device input).
Here's the API I've got so far. I have an InputHandler
class which has these public methods:
// c++
void beginPoint(float x, float y, void* touchUID);
void endPoint(float x, float y, void* touchUID);
void movePoint(float x, float y, void* touchUID);
void cancelPoint(float x, float y, void* touchUID);
which correspond to - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
and so on within my ViewController.mm
.
I need to track the individual fingers separately, and the documentation makes it pretty clear that each finger gets assigned its own UITouch instance (i.e. the UITouch object actually represents a specific finger). This would indicate that I can get away with using the pointer value as a Unique ID for a finger-tracking point.
However, I run into trouble here:
I need to learn about bridged casts now. I'll be honest, I don't know a thing about how ARC works because I barely understand retain/release yet. I am fully invested in shared_ptr
and friends from C++ to help me manage complex systems.
I clearly need to just leave the UITouch* touch
alone, and let it be retained/release/ARC'd exactly as if I did not access it. But even for something as basic as this, it is not clear which of the three bridged cast options I need to use.