Basic Objective-C and objectivec tutorials
NSMutableArray-InsertObject: atIndex:And-ReplaceObjectAtIndex: withObject:Yes, that is, it can be achieved through insert and replace.
Example:
// Reduce button listening-(void) onSubBtnPressed :( UIButton *) sender {NIDPRINTMETHODNAME (); NSInteger times = [[_ serviceNumList objectAtIndex: _ servicePos] integerValue]; if (times <= 1) {return;} times --; // reduce // change the array data [_ serviceNumList replaceObjectAtIndex: _ servicePos withObject: [NSNumber numberWithInteger: times]; // set the data UITextField * mo = [_ timesFieldArray objectAtIndex: _ servicePos]; NSAttributedString * timesText = [[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @ "% ld ", (long) [[_ serviceNumList objectAtIndex: _ servicePos] integerValue]; // set the text [mo setAttributedText: timesText]; _ totalPrice = (float) ([_ goodsList [_ servicePos] [@ "Price"] floatValue]/100.0) * [[_ serviceNumList objectAtIndex: _ servicePos] integerValue]; [_ totalPriceLabel setText: [NSString stringWithFormat: @ "% 0.1f", _ totalPrice];}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.