Reputation: 65
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 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?
Upvotes: 1
Views: 213
Reputation: 49354
// sampleObjC.m
#include sampleC.h
- (void)myMethod {
NSString *string = [NSString stringWithUTF8String:display()];
NSLog(@"%@", string);
}
Upvotes: 3