开发者

passing a string value from C function to Objective code in Xcode

I need to use a returned value of a C function in objective C..for Ex:consider a file samplec.h & samplec.c..It contains method definition for display i.e..

char *display()
{
    char *b="Hi";
    printf("%s",b);
    return b; 
}

This returned value开发者_StackOverflow社区 should be called and used in objective C function i.e..in sampleObjC.m which exist in same project. Can anybody help me with an idea how to do this or any alternatives if exist for passing string value from c file to objective c file in a same project?


// sampleObjC.m
#include sampleC.h

- (void)myMethod {
    NSString *string = [NSString stringWithUTF8String:display()];
    NSLog(@"%@", string); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜