ディクショナリ値の配列があり、個々の配列項目に対してカウンター メソッドを実装しましたが、最終的なカウンター値の取得に問題がありました。個々のカウンター値を追加していました。
ここにソースコードがあります。
-(void)getData
{
[lReportArr removeAllObjects];
lMetaCount = 0;
NSMutableArray *lTempArr = [[NSMutableArray alloc] initWithArray:lMetaArray];
NSLog(@"Metabolic Array:-%@", lTempArr);
for (int i = 0; i < [lTempArr count]; i++)
{
NSMutableDictionary *lDict = [lTempArr objectAtIndex:i];
NSString *lTitle = [lDict objectForKey:@"title"];
//Glucose Low count
if ([lTitle rangeOfString:@"Glucose reading : Low"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"Low BG:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
//Glucose High count
else if ([lTitle rangeOfString:@"Glucose reading : High"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"High BG:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
//Wrong Dose Cause count
else if([lTitle rangeOfString:@"Low Cause: Wrong Dose"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"LG Wrong Dose:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
else if([lTitle rangeOfString:@"High Cause: Wrong Dose"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"HG Wrong Dose:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
//Symptoms Cause count
else if([lTitle rangeOfString:@"Low Cause: Illness"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"LG Illness:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
else if([lTitle rangeOfString:@"High Cause: Illness"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"HG Symptoms:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
//LG n HG Treatment count
else if([lTitle rangeOfString:@"Treatment: Emergency Room"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"Emergency Room:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
else if([lTitle rangeOfString:@"Treatment: Hospitalization"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"Hospitalization:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
else if([lTitle rangeOfString:@"Treatment: Extra MD Office"].length > 0)
{
lMetaCount++;
NSString *lCount = [NSString stringWithFormat:@"Extra MD Office:%d",lMetaCount];
[lDict setValue:lCount forKey:@"metabolicCount"];
}
[lReportArr addObject:lDict];
}
}