FirebaseDatabase Framework Reference Stay organized with collections Save and categorize content based on your preferences.
MutableData
classMutableData:NSObjectAMutableData instance is populated with data from a Firebase Database location. When you are usingrunTransactionBlock(_:), you will be given an instance containing the current data at that location. Your block will be responsible for updating that instance to the data you wish to save at that location, and then returning usingTransactionResult.success(withValue:).
To modify the data, set its value property to any of the Objective-C types supported by Firebase Database, or any equivalent natively bridgeable Swift type:
NSNumber(includes booleans)NSDictionaryNSArrayNSStringnil/NSNullto remove the data
Note that changes made to a childMutableData instance will be visible to the parent.
Returns boolean indicating whether this mutable data has children.
Declaration
Swift
funchasChildren()->BoolReturn Value
YES if this data contains child nodes.
Indicates whether this mutable data has a child at the given path.
Declaration
Swift
funchasChild(atPathpath:String)->BoolParameters
pathA path string, consisting either of a single segment, like‘child’, or multiple segments, ‘a/deeper/child’
Return Value
YES if this data contains a child at the specified relative path
Used to obtain a
MutableDatainstance that encapsulates the data at the given relative path. Note that changes made to the child will be visible to the parent.Declaration
Swift
funcchildData(byAppendingPathpath:String)->MutableDataParameters
pathA path string, consisting either of a single segment, like‘child’, or multiple segments, ‘a/deeper/child’
Return Value
A
MutableDatainstance containing the data at the given path
To modify the data contained by this instance of
MutableData, set this to any of the Objective-C types supported by Firebase Database, or any equivalent natively bridgeable Swift type:NSNumber(includes booleans)NSDictionaryNSArrayNSStringnil/NSNullto remove the data
Note that setting this value will override the priority at this location.
Declaration
Swift
varvalue:Any?{getset}Return Value
The current data at this location as a native object
Set this property to update the priority of the data at this location. Can be set to any of the following Objective-C types supported by Firebase Database, or any equivalent natively bridgeable Swift type:
NSNumber(includes booleans)NSStringnil/NSNullto remove the data
Declaration
Swift
varpriority:Any?{getset}Return Value
The priority of the data at this location
Declaration
Swift
varchildrenCount:UInt{get}Return Value
The number of child nodes at this location
An enumeration of the children at this location.
for var child in data.children { // … }
Note that this enumerator operates on an immutable copy of the child list. So, you can modify the instance during iteration, but the new additions will not be visible until you get a new enumerator.
Declaration
Swift
varchildren:NSEnumerator{get}Declaration
Swift
varkey:String?{get}Return Value
The key name of this node, or
nilif it is the top-most location
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-11 UTC.