I have a function written in C that is rather large and currently is only running in the main() function of a C file while I have been using to test it out. Here is it's declaration
void getData(const char* encodedBuffer, int user);
If you would like to see the contents of getData Here is the pastebin for it.
As of now I'm just passing in encodedBuffer which I will have a global variable that is getting updated by the getData
function.
I would like to know what the proper way is to turn a C based function like this into a Objective-C protocol method. Right now I'm setting it up like this
iDriver.h (my interface/protocol)
#import <Foundation/Foundation.h>
@protocol iDriver <NSObject>
-(void)getData;
-(void)cancel;
@end
DriverOne.h (Class that actually implements the protocol method)
#import <Foundation/Foundation.h>
#import "iDriver.h"
@interface DriverOne : NSObject <iDriver>
@end
DriverOne.m
#import "DriverOne.h"
@implementation DriverOne
enum Status getData(char* encodedBuffer, int user)
{
// Copy C code which I showed in the link earlier
// to above into this method. I will want it to return a status
// and populate a global variable with the data.
}
My thought is that I shouldn't really run into any issues doing this since Objective-C is a superset of C but just copying the C code into a method like that be problematic?