Objective-C - 改变NSMutableArray的特定元素
来源:互联网 发布:软件外包文章 编辑:程序博客网 时间:2024/06/06 10:04
NSMutableArray修改元素, 使用-insertObject: atIndex: 和-replaceObjectAtIndex: withObject: 都可以, 即通过插入(insert)和替换(replace)可以实现.
示例:
// 减少按钮监听- (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]];}
2 0
- Objective-C - 改变NSMutableArray的特定元素
- Objective-C - NSMutableArray添加NSInteger元素
- Objective-c - NSArray(NSMutableArray)
- Objective-c - NSArray(NSMutableArray)
- Objective-c - NSArray(NSMutableArray)
- Objective-C----NSArray、NSMutableArray
- Objective-C 【NSMutableArray】
- Objective-C NSArray & NSMutableArray
- Objective-c之NSArray(NSMutableArray)
- NSMutableArray 可变数组-Objective-C
- Objective-c之NSArray(NSMutableArray)
- Objective-C基础-NSArray & NSMutableArray
- Objective-c之NSArray(NSMutableArray)
- Objective-C 之 NSArray 与 NSMutableArray 的区别
- Objective-C中NSArray和NSMutableArray的基本用法
- Objective-C NSArray和NSMutableArray的详解 使用
- Objective-C中NSArray和NSMutableArray的基本用法
- Objective-C中NSMutableArray的创建及使用
- lucene入门demo
- ECharts使用——封装类库的使用20150713
- 【zoj】【Attack on Titans】
- CentOS 7.0编译安装Nginx+MySQL+PHP
- 大型高并发高负载web应用系统架构-数据库架构策略
- Objective-C - 改变NSMutableArray的特定元素
- dp cf C. Mr. Kitayuta, the Treasure Hunter
- linux declare
- 1、cocos2d-x Lua安装配置
- linux下产生core文件以及不产生core文件的条件-----调试例程
- 遮罩层
- python requests的安装与简单运用
- 三户模型
- 报错:Could not find artifact com.gzydt.report:gzydt-report:xml:features:1.0.0 in maven.central.repo