[英]Objective-c calling C function
Hello i want to call ac Function from an objective c method how can i do that? 您好,我想从目标C方法调用ac函数,我该怎么做?
here is my function 这是我的功能
static BOOL test () {
....
if(...){
return YES;
}else{
return NO;
}
....
}
Just as you will in a C program: 就像在C程序中一样:
-(void) myVoidMethod {
BOOL res;
res = test();
}
Don't forget to declare / include relevant header (again, just like in a C program). 不要忘记声明/包含相关的头文件(同样,就像在C程序中一样)。
Also, as daknøk mentioned, Objective-C is a strict superset of C, so what works with C - works with Objective-C. 而且,正如daknøk所提到的,Objective-C是C的严格超集,因此与C一起使用的东西-与Objective-C一起使用。
you can call c functions from object-c function in the fallowing way... 您可以通过休闲方式从object-c函数调用c函数...
-(void)viewDidLoad
{
// calling the c function from objective-c function
someFunctionName();
}
this is my object-c function 这是我的object-c函数
void someFunctionName()
{
// write logic what you want in this function...
int a ,b;
a=10;
b=20
printf("A value is %d \n B value is %d",a,b);
}
this is my c function ... 这是我的C函数...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.