Hye,
I would like to mix C++ and objective-C but I can't understand why there is so mush errors.
In this example I tried to put Objective-C UIView type in an C++ class.
Environnement.h
ifndef ENVIRONNEMENT_H
define ENVIRONNEMENT_H
class Environnement{
private :
Environnement();
~Environnement();
protected:
static Environnement* instance;
public:
static const int WIDTH = 1024;
static const int HEIGHT = 768;
static Environnement* getInstance();
static void freeEnvironnement();
UIView* getScene();
};
endif
Environnement.mm
include "Environnement.h"
import
import
UIView* canvas = nil;
Environnement* Environnement::instance = 0;
Environnement::Environnement(){
canvas = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Environnement::WIDTH, Environnement::HEIGHT)];
}
Environnement::~Environnement(){
[canvas release];
}
Environnement* Environnement::getInstance(){
if(instance){
instance = new Environnement();
}
return instance;
}
void Environnement::addAgent(Agent* ag) const{
//[canvas addSubview:ag->getBodyInterface()];
}
void Environnement::freeEnvironnement(){
delete instance;
}
UIView* Environnement::getScene(){
return canvas;
}
I tried several solutions in order to put UIView* in the *.h file but at each time I have a thousand of errors. Why? Can anyone have a solution?