I am creating a label (CorePlot) object in a for loop and trying to add it to NSMutableSet which I need to pass a a parameter.
Strangely only one object if added to the NSMutableSet (first one) and others are not added.
Looks like I am missing something very basic.
Any advice?
I am attaching screenshots of the code as I want to show the values held by the NSSet object.
Image 1 - Objects gets added to NSMutableArray but not to NSSet Forming From that array
Code used in Image 1 -
NSArray *months = [NSArray arrayWithObjects:@"Oct",@"Nov",@"Dec",@"Jan",@"Feb",nil];
NSMutableArray *xLabels = [[NSMutableArray alloc] init];
for (NSString *month in months) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:month textStyle:axisTextStyle];
[xLabels addObject:label];
}
NSSet *xLabelSet = [NSSet setWithArray:xLabels];
x.axisLabels = xLabelSet;
Image 2 - Objects not getting added to NSMutableSet
Code used in Image 2 -
NSArray *months = [NSArray arrayWithObjects:@"Oct",@"Nov",@"Dec",@"Jan",@"Feb",nil];
//NSMutableArray *xLabels = [[NSMutableArray alloc] init];
NSMutableSet *xLabelSet = [[NSMutableSet alloc] initWithCapacity:[months count]];
for (NSString *month in months) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:month textStyle:axisTextStyle];
[xLabelSet addObject:label];
}
//NSSet *xLabelSet = [NSSet setWithArray:xLabels];
x.axisLabels = xLabelSet;