typedef enum
{mLineType = 10,
mBarType,
mStackedType
}ChartType;
Now you know how to create enum, how do you use it though ? You create a class say MyChart and have ChartType as one of the member variable.
@interface MyChart : UIView
{
NSArray *valueArray;
ChartType type;
@private
int levels_;
float yOffset;
float xOffset;
}
@property(nonatomic,retain)NSArray *valueArray;
@property(nonatomic,assign) ChartType type;
-(void)drawGraph;
@end
Now you have create an instance of MyChart and define its type as following.
MyChart *chart =[[MyChart alloc]initWithFrame:a];
chart.type=mLineType;
[chart drawGraph];
[self.view addSubview:chart];
Now there is this unique problems in enums you may come across sometime that what if 2 enums ended up having some values same, your code will show ERROR, how to solve this ? See you in NEXT ARTICLE.
ReplyDeletenice blogs
Sports Packsms ACT SPO and send it to 50000. And to deactivate the service sms DEACT SPO and send it to 50000
Charges
Rs. 7/Week.