iphone - Best iOS data structure to store sizes and colours of a product -


i developing ios application deals products. these products can have sizes , colours (clothes, example). need data structure store available colours , sizes current product (for 1 product @ time). price has part of data structure, since every colour-size combination might have different price, url product image of specified size.

i have thought of two-dimensional array (i.e. nsarrays of nsarray) first dimension colour , second size , content of cell price , url, there inconvenience when product has sizes without colours or vice versa.

is there other better data structure satisfies needs, or choice best?

thanks!

you should build own data structure(s) have layers. example:

@interface variant : nsobject @property (nonatomic, strong) uicolor *color; @property (nonatomic) cgfloat price; @property (nonatomic, strong) nsstring *size; // might want better structure hold @end  @interface product : nsobject @property (nonatomic, strong) nsstring *title; @property (nonatomic, strong) nsarray *variants; // array of variant's @end 

if nest arrays arrays structure , benefits of object oriented programming.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -