FIRMutableData.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * A FIRMutableData instance is populated with data from a Firebase Database location.
  20. * When you are using runTransactionBlock:, you will be given an instance containing the current
  21. * data at that location. Your block will be responsible for updating that instance to the data
  22. * you wish to save at that location, and then returning using [FIRTransactionResult successWithValue:].
  23. *
  24. * To modify the data, set its value property to any of the native types support by Firebase Database:
  25. *
  26. * + NSNumber (includes BOOL)
  27. * + NSDictionary
  28. * + NSArray
  29. * + NSString
  30. * + nil / NSNull to remove the data
  31. *
  32. * Note that changes made to a child FIRMutableData instance will be visible to the parent.
  33. */
  34. NS_SWIFT_NAME(MutableData)
  35. @interface FIRMutableData : NSObject
  36. #pragma mark - Inspecting and navigating the data
  37. /**
  38. * Returns boolean indicating whether this mutable data has children.
  39. *
  40. * @return YES if this data contains child nodes.
  41. */
  42. - (BOOL) hasChildren;
  43. /**
  44. * Indicates whether this mutable data has a child at the given path.
  45. *
  46. * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child'
  47. * @return YES if this data contains a child at the specified relative path
  48. */
  49. - (BOOL) hasChildAtPath:(NSString *)path;
  50. /**
  51. * Used to obtain a FIRMutableData instance that encapsulates the data at the given relative path.
  52. * Note that changes made to the child will be visible to the parent.
  53. *
  54. * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child'
  55. * @return A FIRMutableData instance containing the data at the given path
  56. */
  57. - (FIRMutableData *)childDataByAppendingPath:(NSString *)path;
  58. #pragma mark - Properties
  59. /**
  60. * To modify the data contained by this instance of FIRMutableData, set this to any of the native types supported by Firebase Database:
  61. *
  62. * + NSNumber (includes BOOL)
  63. * + NSDictionary
  64. * + NSArray
  65. * + NSString
  66. * + nil / NSNull to remove the data
  67. *
  68. * Note that setting this value will override the priority at this location.
  69. *
  70. * @return The current data at this location as a native object
  71. */
  72. @property (strong, nonatomic, nullable) id value;
  73. /**
  74. * Set this property to update the priority of the data at this location. Can be set to the following types:
  75. *
  76. * + NSNumber
  77. * + NSString
  78. * + nil / NSNull to remove the priority
  79. *
  80. * @return The priority of the data at this location
  81. */
  82. @property (strong, nonatomic, nullable) id priority;
  83. /**
  84. * @return The number of child nodes at this location
  85. */
  86. @property (readonly, nonatomic) NSUInteger childrenCount;
  87. /**
  88. * Used to iterate over the children at this location. You can use the native for .. in syntax:
  89. *
  90. * for (FIRMutableData* child in data.children) {
  91. * ...
  92. * }
  93. *
  94. * Note that this enumerator operates on an immutable copy of the child list. So, you can modify the instance
  95. * during iteration, but the new additions will not be visible until you get a new enumerator.
  96. */
  97. @property (readonly, nonatomic, strong) NSEnumerator<FIRMutableData *>* children;
  98. /**
  99. * @return The key name of this node, or nil if it is the top-most location
  100. */
  101. @property (readonly, nonatomic, strong, nullable) NSString* key;
  102. @end
  103. NS_ASSUME_NONNULL_END