I have an NSMutableArray with multiple products. Each product has an amount. I want to update the amount of the associated product when a stepper is clicked. But all my products (whole NSMutableArray) are updated with the amount of the stepper.
NSInteger index = stepper.tag;
Product *p = [products objectAtIndex:index];
p.amount = [NSNumber numberWithDouble:stepper.value];
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%d", stepper.tag] message:@"test" delegate:nil cancelButtonTitle:@"ok"otherButtonTitles:nil];
// [alert show];
for (Product *p in products) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@", p.amount] message:p.name delegate:nil cancelButtonTitle:@"ok"otherButtonTitles:nil];
[alert show];
}
Does anyone have a solution?