开发者

In Objective-C Can I Treat a Property As An Array?

In good ole C I can do this:

int array[5];
int *iptr = array;

I have an Obj-C class with an ivar:

开发者_如何学Go
    float   *m_quad;

exposed via a synthesized @propery:

@property (nonatomic) float *quad;

Is there anyway to do this:

float f = myClass.quad[2];

Assuming of course I have malloc'd and set values for m_quad?

Thanks,

Doug


Should work of the bat. I have an ivar and property

float diffuseColor_[4];
@property (readonly, nonatomic) float* diffuseColor;

The property is not synthesized, but using a simple accessor I can write

- (float*) diffuseColor
{
    return diffuseColor_;
}


object.diffuseColor[3] = 1;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜