Wednesday, April 20, 2011

how do you set @synthesize for an array?

Hello. How do you set @synthesize for an array like: float rgb[3]. Also, is the @property line: @property(nonatomic, assign) float rgb?? Thanks

From stackoverflow
  • I don't believe that you can define the array size in the interface if you wish you use it as a property. You would need to do something like: (pardon any syntactical mistakes, this is from memory)

    @interface MyClass : NSObject {
        float *rgb;
    }
    
    @propery (nonatomic, assign) float *rgb;
    

    Then in your implementation:

    @implementation MyClass
    
    @synthesize rgb;
    
    @end
    

    Then you would have to initialize the pointer using some C functions, such as:

    rgb = (float *)malloc(sizeof(float) * 3);
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.