How can I Initialize
and allocate
multiple objects with different name and pass it to the NSArray
. from Below code the object is initialized once in loop and I need to initialized multiple times as per the For loop will go with different name..and then pass it to NSArray
.please check the code below..
when For loop will start means i=0 ..initialized item would betempItemi
now next time when i=1 and i=2 the tempItemi
name will be same .how can i change this with in loop..and pass it to NSArray *items
for (int i = 0; i< [Array count]; i++)
{
id object = [Array objectAtIndex:i];
if ([object isKindOfClass:[NSDictionary class]])
{
NSDictionary *objDict = (NSDictionary *)object;
ECGraphItem *tempItemi = [[ECGraphItem alloc]init];
NSString *str = [objDict objectForKey:@"title"];
NSLog(@"str value%@",str);
float f=[str floatValue];
tempItemi.isPercentage=YES;
tempItemi.yValue=f;
tempItemi.width=30;
NSArray *items = [[NSArray alloc] initWithObjects:tempItemi,nil];
//in array need to pass all the initialized values
[graph drawHistogramWithItems:items lineWidth:2 color:[UIColor blackColor]];
}
}