-1

We have created common C++ interface & have platform specific concrete implementation. Now for iPad we do not seem to find any direct mechanism in objective C for notification. Apparently there does not seem to be any way in objective C to notify common C++ codes once HTTP response is received (to pass the response to common C++ codes).

Has anyone tried to notify C++ codes from Objective C passing an object?

  • Not very good variant, but if you don't find something better, you could use a pointer to some callback function implemented in C++ and call it from within your Obj C code on HTTP response event. – Ivan Oct 22 '14 at 13:25
  • 2
    What do you mean by "notification" ? Probably you need to check the "Obj-C++" with `.mm` file extension – deimus Oct 22 '14 at 13:31
  • Hi Ivan, Thanks for the quick response. The idea of using pointer within objective C to a callback function implemented in C++ can help.Currently got stuck with some other work but we will surely try this route. We have never registered pointer this way, do you know of any such sample/example? Thanks Rakesh – Rakesh Desai Oct 27 '14 at 07:02

2 Answers2

1

I d not understand what you mean with the "notify" thing but if you want to be able to call c++ from objective-c name the file .mm instead of .m. That makes it possible to use both c++ and objective-c in the same file.

Peter Segerblom
  • 2,773
  • 1
  • 19
  • 24
1

It's really unclear what you're asking,
anyway
If you're trying to call C++ code from objective c
Rename your objective c file to .mm extension
So for example if you have ViewController.m rename it to ViewController.mm

If you want to crate PIMPL, refer to this question,
Calling Objective-C method from C++ method?
The answer covers topics, how to interact from c++ to objective c objects.

Community
  • 1
  • 1
l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • Thanks for the suggested link, we are supposed to do this also but the issue raised in my question is for reverse situation i.e. C++ from Objective C. Looks like Ivan's comment might help. – Rakesh Desai Oct 27 '14 at 07:03