I have a class that interprets accelerometer data (which makes it the model, right?) and then passes some info to the controller, whom it shouldn't know anything about beyond that it's an NSObject.
For example, in this code, the accelerometer interpreter determines that the device was moved abruptly enough to send a message to the controller:
The issue is, xCode is giving me a warning that "Method '-pressUp' not found".
But I've already made sure that the controller has such a method before I tell it to run it. The app runs fine, but I'd rather make sure xCode doesn't give me false warnings, so I want to make sure, am I using introspection properly? I figure that having the accelerometer interpreter import the controller is a poor programing choice, because then it becomes too tightly integrated into this program and can't be as easily integrated into another program in the future (or if I decided to make it possible to change within this program which controller the accelerometer interpreter sends its data to.)
Edit: I just changed [controller pressUp]; to [controller performSelectorselector(pressUp)]; which removed the compiler warning... is this actually somehow better?
For example, in this code, the accelerometer interpreter determines that the device was moved abruptly enough to send a message to the controller:
Code:
if ((zData - lastStoredZData < -0.10) && ([controller respondsToSelector:@selector(pressUp)]))
{
[controller pressUp];
}
lastStoredZData = zData;
The issue is, xCode is giving me a warning that "Method '-pressUp' not found".
But I've already made sure that the controller has such a method before I tell it to run it. The app runs fine, but I'd rather make sure xCode doesn't give me false warnings, so I want to make sure, am I using introspection properly? I figure that having the accelerometer interpreter import the controller is a poor programing choice, because then it becomes too tightly integrated into this program and can't be as easily integrated into another program in the future (or if I decided to make it possible to change within this program which controller the accelerometer interpreter sends its data to.)
Edit: I just changed [controller pressUp]; to [controller performSelectorselector(pressUp)]; which removed the compiler warning... is this actually somehow better?