Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用原生objective-c方法进行c回调_Objective C_C - Fatal编程技术网

使用原生objective-c方法进行c回调

使用原生objective-c方法进行c回调,objective-c,c,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(vo

我想从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回调原型中传递Objective c方法。但是你可以从c回调定义重定向到你的目标c函数

示例

//在您的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) 
//在ur回调激发之前,在ur init定义中为ur IVAr赋值

myclass = self ;
or
myclass = delegate;
//在C回调函数中像这样使用上面的IVAR

static void callback(void)
{

[myclass Your Function];

 }

不能在c回调原型中传递Objective c方法。但是你可以从c回调定义重定向到你的目标c函数

示例

//在您的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) 
//在ur回调激发之前,在ur init定义中为ur IVAr赋值

myclass = self ;
or
myclass = delegate;
//在C回调函数中像这样使用上面的IVAR

static void callback(void)
{

[myclass Your Function];

 }

你不能。
回调
参数需要一个没有参数且返回类型为void的函数。你不能传递Objective-C方法。谢谢。好的,我可以传递上面的C方法,包括Objective-C对象吗?我的意思很简单,我如何通过C回调方法控制UIbutton或webview?看看是否可以使用
objc\u msgsend
?你不能。
回调
参数需要一个没有参数且返回类型为void的函数。你不能传递Objective-C方法。谢谢。好的,我可以传递上面的C方法,包括Objective-C对象吗?我的意思很简单,我如何通过C回调方法控制UIbutton或webview?看看是否可以使用
objc\u msgsend
?谢谢你的回复。我们有什么窍门可以从当前类调用方法吗?在当前类中调用你的C?然后在@implementation之前的ur.m中声明你的ivar like
YourClassName*myclass
;(无需创建实例,只需声明)并在viewdidload assign
myclass=self中
然后使用myclass而不是Callback中的“self”调用函数void*我昨天尝试过这样做,但最近得到的结果是,在类中没有名称可见的方法。大家好,我也在尝试这样做。但是,我无法得到它。我想做的是,我有一个回调函数,它是静态void。在这个静态回调函数中,我需要访问我的局部变量和局部方法。但我无法访问它。请你帮我把这个拿出来好吗?谢谢你的回复。我们有什么窍门可以从当前类调用方法吗?在当前类中调用你的C?然后在@implementation之前在ur.m声明你的ivar像
你的类名*myclass
;(无需创建实例,只需声明)并在viewdidload assign
myclass=self中
然后使用myclass而不是Callback中的“self”调用函数void*我昨天尝试过这样做,但最近得到的结果是,在类中没有名称可见的方法。大家好,我也在尝试这样做。但是,我无法得到它。我想做的是,我有一个回调函数,它是静态void。在这个静态回调函数中,我需要访问我的局部变量和局部方法。但我无法访问它。你能帮我把这个拿出来吗?