GTLRUtilities.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (c) 2011 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #import <Foundation/Foundation.h>
  16. NS_ASSUME_NONNULL_BEGIN
  17. // Helper functions for implementing isEqual:
  18. BOOL GTLR_AreEqualOrBothNil(id _Nullable obj1, id _Nullable obj2);
  19. BOOL GTLR_AreBoolsEqual(BOOL b1, BOOL b2);
  20. // Helper to ensure a number is a number.
  21. //
  22. // The Google API servers will send numbers >53 bits as strings to avoid
  23. // bugs in some JavaScript implementations. Work around this by catching
  24. // the string and turning it back into a number.
  25. NSNumber *GTLR_EnsureNSNumber(NSNumber *num);
  26. @interface GTLRUtilities : NSObject
  27. // Key-value coding searches in an array
  28. //
  29. // Utilities to get from an array objects having a known value (or nil)
  30. // at a keyPath
  31. + (NSArray *)objectsFromArray:(NSArray *)sourceArray
  32. withValue:(id)desiredValue
  33. forKeyPath:(NSString *)keyPath;
  34. + (nullable id)firstObjectFromArray:(NSArray *)sourceArray
  35. withValue:(id)desiredValue
  36. forKeyPath:(NSString *)keyPath;
  37. @end
  38. NS_ASSUME_NONNULL_END