使用本机objective-c方法进行C回调

我想从c回调一个客观的c方法。

//c int gameEngineCallback(int buttontype,void (*callback)(void)) //using above function gameEngineCallback(roundButton,callback); //this works fine but I want to call objective c native method instead of this static void callback(void){ } 

你无法在C CallBack protoType中传递Objective c方法。 但你可以从C回调定义重定向到你的Objective cfunction。

//在你的Ivar的公开声明中添加以下行

 id myclass; // if ur not Sure about ur class name or u have to redirect to ur delegate class or YourClassName *instanceof class; //(no need to create instance just declartion) 

//在你回调之前激活你在你的init定义中为你的IVAr分配值

 myclass = self ; or myclass = delegate; 

//在你的C回调函数中使用上面的IVAR

 static void callback(void) { [myclass Your Function]; }