GTLRUtilities.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef SKIP_GTLR_DEFINES
  17. #import "GTLRDefines.h"
  18. #endif
  19. NS_ASSUME_NONNULL_BEGIN
  20. // Helper functions for implementing isEqual:
  21. BOOL GTLR_AreEqualOrBothNil(id _Nullable obj1, id _Nullable obj2);
  22. BOOL GTLR_AreBoolsEqual(BOOL b1, BOOL b2);
  23. // Helper to ensure a number is a number.
  24. //
  25. // The Google API servers will send numbers >53 bits as strings to avoid
  26. // bugs in some JavaScript implementations. Work around this by catching
  27. // the string and turning it back into a number.
  28. NSNumber *GTLR_EnsureNSNumber(NSNumber *num);
  29. @interface GTLRUtilities : NSObject
  30. // Key-value coding searches in an array
  31. //
  32. // Utilities to get from an array objects having a known value (or nil)
  33. // at a keyPath
  34. + (NSArray *)objectsFromArray:(NSArray *)sourceArray
  35. withValue:(id)desiredValue
  36. forKeyPath:(NSString *)keyPath;
  37. + (nullable id)firstObjectFromArray:(NSArray *)sourceArray
  38. withValue:(id)desiredValue
  39. forKeyPath:(NSString *)keyPath;
  40. @end
  41. NS_ASSUME_NONNULL_END