What's the best way of wrapping C++ strings in Objective-C/C++? I tried using NSStrings with pointers (NSString*) but i'm having memory issues as it's throwing EXC_BAD_ACCESS issues at the compiler level during runtime. Using ObjC++ double to C++ double for my numerical data seemingly works fine but the strings are proving to be a huge headache. I've seen a few ways of doing this but none were very clear.
Included are the Objective-C++ files I'm using.
TestObjC.h
#import <Foundation/Foundation.h>
@interface TestObjC : NSObject
- (double) TestCPP: (double) A : (double) B : (double) C :(double) D : (double) E : (double) F : (NSString*) Caller : (NSString*) Sector : (NSString*) OutPut;
@endTestObjC.mm
#import “TestObjC.h”
#import “TestCPP.h"
@interface TestObjC(){
Test wrapped;
}
@end
NSString *Caller = Caller;
string Call = [Caller UTF8String];
NSString *Sector = Sector;
string Sect = [Sector UTF8String];
NSString *OutPut = OutPut;
string OP = [OutPut UTF8String];
@implementation TestObjC
- (double) TestCPP: (double) A : (double) B : (double) C :(double) D : (double) E : (double) F : (NSString*) Caller : (NSString*) Sector : (NSString*) OutPut;
@end
return wrapped.TesterFunction((double) A, (double) B, (double) C, (double)D, (double)E, (double) F, Call, Sect,OP);
}
@end