iOS 数组查询

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

  if (matchingDeviceIDIndex != NSNotFound) {
    //有找到
  } else {
    //没有
  }
posted @ 2018-03-03 15:19  judy_long  阅读(109)  评论(0)    收藏  举报