c++ - Adding functions to an existing Objective-C class raises error -


i'm writing c++ wrapper nsimage class , i'm having trouble additional functions wrote. here's brief summary:

nsimageextras.h

@interface nsimage (myextensions) -(nsstring*) myextrafunction; @end 

nsimageextras.mm

#import "nsimageextras.h"  @implementation nsimage (myextensions) -(nsstring*) myextrafunction {     return @"hello world"; } @end 

nsimagewrapper.h

class nsimagewrapper { public:     // nsimage of type (nsimage*)     nsimagewrapper(void* nsimage) {myimage = nsimage;}     ~nsimagewrapper() {}      cfstringref myextrafunction();      // cast (nsimage*)     void* getnsimage() {return myimage;}  private:     void* myimage; }; 

nsimagewrapper.mm

#include "nsimagewrapper.h" #import "nsimageextras.h"  cfstringref nsimagewrapper::myextrafunction() {     return (cfstringref) [(nsimage*) myimage myextrafunction];  } 

this compiles. when try call myextrafunction error raised because function isn't found. if change import "nsimageextra.h" import "nsimageextra.m" works, i'd rather avoid adding .m files in imports.

any idea why happening?

thanks ahead.

you can try import nsimageextras.h in nsimagewrapper.h instead of nsimagewrapper.mm. need include subclass headers in header files.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -