Objective C++: Call Objective C method from C++

Objective C++: Call Objective C method from C++

I’m using NSURLSession to connect to a database. I have this already implemented in C++ for Windows and am trying to get it working on iOS also. I have a .h file derived from a base C++ class that is the header for my .mm file. If I’m correct I have to implement all the functions in my .h file in C++. However NSURLSession is an Objective-C function. How do I call an Objective-C method from my C++ function?

I have a C++ function called Connect() where I make a C++ object m_Delegate that has an alloc and init.

this->m_Delegate = [[PrivateNSURLSessionDelegate alloc] initWihParent:this];
//where PrivateNSURLSessionDelegate is the name of my interface.

That interface has -(bool)NSConnect (with implementation in the @implementation) which I’m trying to call from:

void Connect()
{
    [PrivateNSURLSessionDelegate NSConnect];
    //This however gives me the error: +[PrivateNSRLSessionDelegate NSConnect]: unrecongnized selector sent to class
}

I also tried it using my C++ object

void Connect()
{
    [m_Delegate NSConnect];
    //This gives me a error that is unrecognized selector sent to instance
}

Is there a better way to do this? I basically want to ask the Objective-C to do all the NSURL stuff and send just the data back to the C++.

I’m completely new to Objective-C so any and all help would be greatly appreciated! Thanks!