您的位置:首页 > 移动开发 > Objective-C

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];

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: