0

Im trying to wrap the gloox library in objective-c. I have read this article Making a Objective-C Wrapper for a C++ Library and it is fairly straight forward however it does not cover classes that are inside a namespace. Any thoughts on how to use the technique in the article above only with a namespace? Thanks for the help!

[edit] Think I figured it out add

#ifdef __cplusplus
namespace gloox {
class Client;
}
#endif
Community
  • 1
  • 1
Trent Ahrens
  • 292
  • 3
  • 10

1 Answers1

1

I think the obvious should work when compiled as objective C++:

#if defined __cplusplus
namespace Foo { class MyCPPClass; }   // forward class declaration
#else
/*not sure here*/ /*namespace Foo { typedef struct MyCPPClass MyCPPClass;  }*/ // forward struct declaration
#endif

@interface MyOCClass : NSObject
{
@private
    Foo::MyCPPClass* cppObject;
} 

// methods and properties

@end

The Qt project has a lot of examples for mixing C++ and Objective-C.

silverjam
  • 400
  • 1
  • 7