博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Objective-C - 改变NSMutableArray的特定元素
阅读量:7086 次
发布时间:2019-06-28

本文共 985 字,大约阅读时间需要 3 分钟。

NSMutableArray改动元素, 使用-insertObject: atIndex: -replaceObjectAtIndex: withObject: 都能够, 即通过插入(insert)和替换(replace)能够实现.

演示样例:

// 降低button监听- (void) onSubBtnPressed:(UIButton*) sender {    NIDPRINTMETHODNAME();    NSInteger times = [[_serviceNumList objectAtIndex:_servicePos] integerValue];    if (times <= 1) {        return;    }    times--; // 降低    // 改变数组数据    [_serviceNumList replaceObjectAtIndex:_servicePos withObject:[NSNumber numberWithInteger:times]];    // 设置数据    UITextField *mo = [_timesFieldArray objectAtIndex:_servicePos];    NSAttributedString* timesText =[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld", (long)[[_serviceNumList objectAtIndex:_servicePos] integerValue]]]; // 设置文字    [mo setAttributedText:timesText];    _totalPrice = (float)([_goodsList[_servicePos][@"Price"] floatValue]/100.0)*[[_serviceNumList objectAtIndex:_servicePos] integerValue];    [_totalPriceLabel setText:[NSString stringWithFormat:@"%0.1f", _totalPrice]];}

娱乐

你可能感兴趣的文章
【生物识别】阿里巴巴在移动端核身技术实践
查看>>
Flutter:ListView-ScrollPhysics 详细介绍(翻译)
查看>>
解决 SpringBoot 没有主清单属
查看>>
SAX解析Excel
查看>>
[译] 在 Android P 中使用默认的 TLS 来保护你的用户
查看>>
学习日记 - Object.defineProperty
查看>>
Spring注解专题系类(二)
查看>>
python3、ipython3、setup-tools、pip等环境搭建详细总结
查看>>
react更新state的时候要返回一个全新的引用或者值
查看>>
MobIM-API说明
查看>>
如何在常见业务场景中使用React Hook
查看>>
数据结构系列3 线性表顺序映像的Java实现
查看>>
vue中v-model
查看>>
flex实战
查看>>
python file 文件操作笔记
查看>>
对于MySQL你必须要了解的锁知识
查看>>
从三流小公司到一线大厂,聊聊程序员的成长之道
查看>>
ClassPlaceholder插件:动态修改jar包class文件
查看>>
浅谈Netty中的ChannelPipeline
查看>>
快速排序
查看>>