zoukankan      html  css  js  c++  java
  • 谓词

    http://blog.csdn.net/lmf208/article/details/38345321

    http://blog.csdn.net/jiangwei0910410003/article/details/41923507

    如果是两个 存储自定义  对象的数组  直接 进行过滤 。。 

    #import <Foundation/Foundation.h>

    @interface person : NSObject

    @property (nonatomic,strong) NSString *num;

    @property (nonatomic,strong) NSString *name;

    + (instancetype)personWithNum:(NSString *)num name:(NSString *)name;

    @end

    初始化 自己自定义的实力  , 并放在不同的两个数组中

     person *a1 = [person personWithNum:@"1" name:@"我0"];

        person *a2 = [person personWithNum:@"2" name:@"我1"];

        person *a3 = [person personWithNum:@"3" name:@"我2"];

        person *a4 = [person personWithNum:@"1" name:@"我0"];

        person *a5 = [person personWithNum:@"5" name:@"我4"];

        person *a6 = [person personWithNum:@"6" name:@"我5"];

        person *a7 = [person personWithNum:@"7" name:@"我6"];

        person *a8 = [person personWithNum:@"8" name:@"我7"];

        

        NSArray *array1 = [NSArray arrayWithObjects:a1,a2,a3,a8, nil];

        NSArray *array2 = [NSArray arrayWithObjects:a3,a4,a5,a6,a7,a1, nil];

        //使用第一个数组  来过滤 第二个数组   SELF.num IN %@.num 判断两个数组中  如果有   对象  num 相同的 就  保存到  result 数组中。

      //  NOT  ( SELF.num IN %@.num)  //就是 对上面的结果 取反 

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.num IN %@.num",array1];

        

        NSArray *result = [array2 filteredArrayUsingPredicate:predicate];

        NSLog(@"%@",result);

  • 相关阅读:
    iis6 , URL重写HTM文件名后,出现真实的HTM文件不能访问的解决
    pe如何安装ios系统
    ASP.NET Word转为PDF
    asp.net 操作word 权限
    windows server 2008 r2 修改远程登入的端口号(3389)
    A
    A Bug
    亲戚
    Kruskal
    HDOJ ——统计难题
  • 原文地址:https://www.cnblogs.com/Seeulater/p/5148379.html
Copyright © 2011-2022 走看看