NSMutableArray与NSMutableIndexSet结合删除NSMutableArray中符合条件的object
2017-05-10 23:19
531 查看
NSMutableArray *mutable = [NSMutableArray arrayWithArray:searchFlightsHistoryArray];
//过期日期搜索记录去重
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
for (int i = 0; i < mutable.count; i++) {
SearchFlightsHistory *indexData = mutable[i];
NSInteger diffDate = [NSDate dayIntervalWithADate:[NSDate date] BDate:indexData.departDate];
if (diffDate < 0) {
[indexSet addIndex:i];
}
}
if (indexSet.count >0) {
[mutable removeObjectsAtIndexes:indexSet];
}
//过期日期搜索记录去重
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
for (int i = 0; i < mutable.count; i++) {
SearchFlightsHistory *indexData = mutable[i];
NSInteger diffDate = [NSDate dayIntervalWithADate:[NSDate date] BDate:indexData.departDate];
if (diffDate < 0) {
[indexSet addIndex:i];
}
}
if (indexSet.count >0) {
[mutable removeObjectsAtIndexes:indexSet];
}
相关文章推荐
- Foundation NSMutableArray遍历,选取出符合条件的所有对象
- iOS: NSMutableArray的方法removeObjectIdenticalTo:inRange:
- iPhone/iOS中保存自定义对象(Custom Object/Custom Class)的数组(NSMutableArray/NSArray)到NSUserDefaults
- 关于UITableView横扫删除的问题 [NSMutableArray removeObjectAtIndex]
- object-c 之NSArray和NSMutableArray的一些操作
- 【iOS】NSMutableArray遍历删除内部元素的问题总结
- NSMutableArray数组循环中删除元素不安全的
- NSMutableArray 删除元素
- object-c中对NSMutableArray中存储对象的内存引用测试
- NSMutableArray基础-创建、添加、删除、替换
- NSMutableArray和NSArray删除相同元素并只保留一个的方法
- iOS: NSMutableArray的方法removeObjectIdenticalTo:
- argument to nsmutablearray method addobject cannot be nil 警告
- 删除可变数组NSMutableArray中的重复数据
- iOS之Object-C基础编程之NSArray和NSMutableArray
- 删除可变数组NSMutableArray中的重复数据
- [并发并行]_[Object-C]_[使用NSMutableArray等非线程安全集合类的注意事项]
- iOS NSMutableArray "removeObjectIdenticalTo" vs "removeObject"
- object-c中对NSMutableArray中存储对象的内存引用测试
- NSMutableArray在alloc init之后再调用addobject还是会崩溃的可能原因有哪些? 出现错误:[__NSArrayI addObject:]: unrecognized sel