I have the data into the mutable array and the value of array is,
{ "20", "40", "50","60", "70"}.
I have stored the string values into the array.
Now i want to total value of the array. Result is : 240
Thanks!
You can do as follows:
int totalSum = 0;
NSmutableArray *arrayData = [[NSmutableArray alloc] init];
[arrayData addObject:@"20"];
[arrayData addObject:@"40"];
[arrayData addObject:@"50"];
[arrayData addObject:@"60"];
[arrayData addObject:@"70"];
for(int i=0; i<[arrayData count];i++)
{
totalSum = totalSum + [[arrayData objectAtIndex:i] intValue];
}
NSLog(@"Total:%d",totalSum);
Please let me know if you have any question.
alloc and init arrayData.