首页 > 技术文章 > iOS 数组查询

viskyly 2018-03-03 15:19 原文

        NSUInteger matchingDeviceIDIndex = [tempArray indexOfObjectPassingTest:^BOOL(TestModel *_Nonnull model, NSUInteger idx, BOOL * _Nonnull stop) {
     //查找第一个符合要求的
          return model.modelID == model.modelID;  //为YES的时候跳出
        }];

  if (matchingDeviceIDIndex != NSNotFound) {
    //有找到
  } else {
    //没有
  }

推荐阅读