I want to declare a simple array of structures This is my code... but it didn't work:
@implementation GLPlane{
GLKVector2 *vertices;
}
-(id)init{
if(self = [super init]){
vertices = {<---- This operation seems to be not allowed.
GLKVector2Make(0.0f, 0.5f),
GLKVector2Make(-0.5f, 0.5f),
GLKVector2Make(0.0f, 0.0f)
};
}
return self;
}
Where is the problem?
If I write the init function that way, using a temporary array it works
-(id)init{
if(self = [super init]){
GLKVector2 tempArray[] = {
GLKVector2Make(0.0f, 0.5f),
GLKVector2Make(-0.5f, 0.5f),
GLKVector2Make(0.0f, 0.0f)
};
vertices = tempArray;
}
return self;
}
Expected Expressionverticeswould be a pointer to a local stack variable and therefore be invalid as soon as the init method returns.