I'm fairly new to Objective-C and I am building an iCloud utility library for our project. I have created an iCloud utility class in Objective-C. I've noticed there are loads of questions on using C++ classes in Objective-C but few the other way around. The problem is, our project (and engine on top of which our project is built) is entirely written in C++ and as such, the objective-c icloud class I have written needs to be accessable from a C++ interface I am writing.
Here is an example:
iCloudUtils.h
#import <Foundation/Foundation.h>
@interface iCloudUtil : NSObject
@property(nonatomic, assign, getter=isAvailable) BOOL iCloudIsAvailable;
@property (assign) NSString *urlToFile;
-(bool) init_iCloud;
-(void) loadDocument: (NSString*)fileUrl;
@end
iCloudUtils.m
#import "iCloudUtil.h"
@synthesize urlToFile = _urlToFile;
@synthesize iCloudIsAvailable = _iCloudIsAvailable;
//////////////////////////////////////////////////////
@implementation iCloudUtil
-(bool) init_iCloud{
//blah blah
}
-(void) loadDocument: (NSString*)fileUrl{
//more blah blah
}
@end
The C++ class I'm attempting to use this from is like so:
iCloudInterface.h
#ifndef __ICloudInterface__
#define __ICloudInterface__
class ICloudInterface {
static ICloudInterface *_instance;
bool iCloudIsAvailable;
public:
ICloudInterface();
~ICloudInterface();
bool init_iCloud();
};
#endif
What I want to do is to be able to create an instance of iCloudUtils in my C++ class, but I can't #include it in my c++ class without getting 200+ errors about "Stray '@' in program". I'm very inexperienced with Objective-C and even less so with mixing it with C++ so could someone help me out with advice on how to achieve this?
Edit: Just to clear it up, i have already attempted to rename the .cpp to .mm but this hasn't fixed the problem.
Edit2: Also, from what I have understood with reading up (please correct me if I am wrong) by changing a file to .mm, any file that includes it must also change to .mm. I can't do this since it would require changing a very very large number of files to suit a single optional class (reminder that this project and its engine are ALL c++ and this is a cross-platform engine and project).