I saw a similar question involving using opaque types, but I don't quite understand the sample code.
I've got some code which works...where I have several C++ data objects stored as instance variables in my controller. I'd like to conform to MVC, and get all of this pushed down into a model object, and not my controller.
So what I have now that works looks like:
@interface WinController : NSWindowController <NSWindowDelegate>
{
cv::Mat object;
}
- (void)setObject:(const cv::Mat&)newObject;
@end
@implementation
- (void)setObject:(const cv::Mat&)newObject
{
object = newObject;
}
@end
And this setObject:
method is called by a different class's method:
- (void)constructObject
{
cv::Mat object = cv::Mat::zeros(3,3,CV_64F);
[myController setObject:object];
}
So I move the C++ object out of the controller and into a model class. The @interface
and @implementation
is exactly the same. Just copied and pasted into a different class.
The constructObject:
method changes to this:
- (void)constructObject
{
cv::Mat object = cv::Mat::zeros(3,3,CV_64F);
[myController.myModel setObject:object];
}
Now when I compile, I get a new warning:
Instance method '-setObject:' not found. (return type defaults to 'id')
So clearly I'm missing some subtlety on why method #1 works, and #2 doesn't.