I am working on an iphone app. I need to call a method on a .mm file. Here is simplified version of the problem:
ViewHelper.h
- (void)testMtd;
ViewHelper.mm (notice this is .mm)
- (void)testMtd{
NSLog(@"Call reached mm");
}
SomeViewController.m (import to ViewHelper.h omitted for clarity)
- (void)someCallerMtd{
NSLog(@"before");
[viewHelper testMtd]; //call does not work
NSLog(@"after");
}
I see “before” and “after” in the log, but “Call reached mm” never gets printed. Are there special rules to call obj c methods in a .mm file? What am I missing here?
First, it has nothing to do with
.mmfile, it is still objective-c clss. Second, Your mistake is not allocatingViewHelper.The solutions is either alloc your
ViewHelperor make(void)testMtdpublicly. depend on what your need.either change your
SomeViewController.m:or change your
ViewHelper: