iOS 对比A,B两个数组 找出A比B多出来的元素

2022-04-19  本文已影响0人  Qy_iOS

    NSMutableArray *dbNsArr = [[NSMutableArray alloc] init];

    NSMutableArray*requestNsArr = [[NSMutableArrayalloc]init];

    for(inti =0; i < dbArr.count; i++) {

        GroupMemberListModel*model = dbArr[i];

        [dbNsArraddObject:model.memberId];

    }

    for(intj =0; j < requestArr.count; j++) {

        GroupMemberListModel*model = requestArr[j];

        [requestNsArraddObject:model.memberId];

    }

    NSMutableSet*dbSet = [NSMutableSetsetWithArray:dbNsArr];

    NSMutableSet*requestSet = [NSMutableSetsetWithArray:requestNsArr];

    [requestSetminusSet:dbSet];

    NSMutableSet*allSet = [NSMutableSetsetWithArray:requestNsArr];

    [dbSetminusSet:allSet];

    [requestSetunionSet:dbSet];

    NSArray*outMemberArr = [requestSetallObjects];

上一篇下一篇

猜你喜欢

热点阅读