static bool objectIsMatch()

in Chisel/Chisel/CHLObjcInstanceCommands.mm [82:105]


static bool objectIsMatch(NSPredicate *predicate, id obj, const std::unordered_set<Class> &classSet)
{
  if (!predicate) {
    return true;
  }

  bool debug = getenv("FINDINSTANCES_DEBUG");

  if (!predicatePrecheck(obj, classSet)) {
    if (debug) {
      printf("%p has class %s but has non objc contents\n", obj, object_getClassName(obj));
    }
    return false;
  }

  @try {
    return [predicate evaluateWithObject:obj];
  } @catch (...) {
    if (debug) {
      printf("%p has class %s but failed predicate evaluation\n", obj, object_getClassName(obj));
    }
    return false;
  }
}