我想声明一个简单的结构数组这是我的代码......但它不起作用:
@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;
}
问题出在哪里?
如果我以这种方式编写 init 函数,则使用临时数组它可以工作
-(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;
}