Reputation: 7847
I'm trying to figure out how to call a c function from an obj-c file. I've seen some good examples of how to do the opposite.
In the example below I have an objective c file. It contains a c function named setup. I want to be able to create an instance of my obj-c file in the regular way and then call the setup function.
#import <Foundation/Foundation.h>
void setup(int,float);
@interface Test : NSObject {
}
@end
#import "Test.h"
#include <stdio.h>
#include <stdlib.h>
void setup(int val1,float val2)
{
//do something with values
}
@implementation Test
@end
Test *test =[Test alloc]init]
//this does not work
test.setup(6,1.4);
Upvotes: 3
Views: 4999
Reputation: 3491
Just call setup(). As declared, is in no way tied to an object - it's just a regular C function.
Upvotes: 11