Wednesday, 11 September 2013

insert object at index updates whole nsmutablearray

insert object at index updates whole nsmutablearray

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 = [[Product alloc] init];
p = [products objectAtIndex:index];
p.amount = [NSNumber numberWithDouble:stepper.value];
[products removeObjectAtIndex:index];
[products insertObject:p atIndex:index];
Someone a solution?
regards

No comments:

Post a Comment