I have a c function in my viewController.m.
int abc(int a, char* b) {
I also have a function
-(void) callIncomingClass { UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
Now I want to call callIncomingClass from the abc function now.
How do you suggest me to do this?
Why I want to call the Objective-C method from a C function, I cannot create a button or do some processing similar to this C function.
If the following code works:
int abc(int a, char* b) { ViewController * tempObj = [[ViewController alloc] init]; [tempObj callIncomingClass]; }
edit: big picture of what I am doing. There is a c-library, i.e. library.c and library.h. The library.h file has a structure that has callback functions. They must be assigned function pointers. so I have a c-function with the signature int abc (int, char *) that needs to be assigned to the callback function in the structure.
This abc function is defined in ViewController.m. Ideally, I wanted it to be defined in a separate file. but that too is normal.
So, now the callback event occurs, I want to create a UIButton with some actions in the view. Since I cannot create a UIButton from a c function, I call the C object method of the ViewController class, which creates the UIButton.
Hope that clears the image regarding how I plan to use this.