Stay organized with collections
Save and categorize content based on your preferences.
FIRDataSnapshot
@interfaceFIRDataSnapshot:NSObject
A DataSnapshot contains data from a Firebase Database location. Any time
you read Firebase data, you receive the data as a DataSnapshot.
DataSnapshots are passed to the blocks you attach with
observe(_:with:) or observeSingleEvent(of:with:). They are
efficiently-generated immutable copies of the data at a Firebase Database
location. They can’t be modified and will never change. To modify data at a
location, use a DatabaseReference (e.g. with setValue(_:)).
Gets a DataSnapshot for the location at the specified relative path.
The relative path can either be a simple child key (e.g. ‘fred’)
or a deeper slash-separated path (e.g. ‘fred/name/first’). If the child
location has no data, an empty DataSnapshot is returned.
Returns the raw value at this location, coupled with any metadata, such as
priority.
Priorities, where they exist, are accessible under the “.priority” key in
instances of NSDictionary. For leaf locations with priorities, the value will
be under the “.value” key.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-11 UTC."],[],[],null,["# FirebaseDatabase Framework Reference\n\nFIRDataSnapshot\n===============\n\n\n @interface FIRDataSnapshot : NSObject\n\nA DataSnapshot contains data from a Firebase Database location. Any time\nyou read Firebase data, you receive the data as a DataSnapshot.\n\nDataSnapshots are passed to the blocks you attach with\n`observe(_:with:)` or `observeSingleEvent(of:with:)`. They are\nefficiently-generated immutable copies of the data at a Firebase Database\nlocation. They can't be modified and will never change. To modify data at a\nlocation, use a DatabaseReference (e.g. with `setValue(_:)`).\n[Navigating and inspecting a snapshot\n------------------------------------](#/Navigating-and-inspecting-a-snapshot)\n\n- `\n ``\n ``\n `\n\n ### [-childSnapshotForPath:](#/c:objc(cs)FIRDataSnapshot(im)childSnapshotForPath:)\n\n `\n ` \n Gets a DataSnapshot for the location at the specified relative path.\n The relative path can either be a simple child key (e.g. 'fred')\n or a deeper slash-separated path (e.g. 'fred/name/first'). If the child\n location has no data, an empty DataSnapshot is returned. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull FIRDataSnapshot *)childSnapshotForPath:\n (nonnull NSString *)childPathString;\n\n #### Parameters\n\n |-------------------------|------------------------------------------------|\n | ` `*childPathString*` ` | A relative path to the location of child data. |\n\n #### Return Value\n\n The DataSnapshot for the child location.\n- `\n ``\n ``\n `\n\n ### [-hasChild:](#/c:objc(cs)FIRDataSnapshot(im)hasChild:)\n\n `\n ` \n Return true if the specified child exists. \n\n #### Declaration\n\n Objective-C \n\n - (BOOL)hasChild:(nonnull NSString *)childPathString;\n\n #### Parameters\n\n |-------------------------|-------------------------------------------------------|\n | ` `*childPathString*` ` | A relative path to the location of a potential child. |\n\n #### Return Value\n\n true if data exists at the specified childPathString, else false.\n- `\n ``\n ``\n `\n\n ### [-hasChildren](#/c:objc(cs)FIRDataSnapshot(im)hasChildren)\n\n `\n ` \n Return true if the DataSnapshot has any children. \n\n #### Declaration\n\n Objective-C \n\n - (BOOL)hasChildren;\n\n #### Return Value\n\n true if this snapshot has any children, else false.\n- `\n ``\n ``\n `\n\n ### [-exists](#/c:objc(cs)FIRDataSnapshot(im)exists)\n\n `\n ` \n Return true if the DataSnapshot contains a non-null value. \n\n #### Declaration\n\n Objective-C \n\n - (BOOL)exists;\n\n #### Return Value\n\ntrue if this snapshot contains a non-null value, else false. \n[Data export\n-----------](#/Data-export)\n\n- `\n ``\n ``\n `\n\n ### [-valueInExportFormat](#/c:objc(cs)FIRDataSnapshot(im)valueInExportFormat)\n\n `\n ` \n Returns the raw value at this location, coupled with any metadata, such as\n priority.\n\n Priorities, where they exist, are accessible under the \".priority\" key in\n instances of NSDictionary. For leaf locations with priorities, the value will\n be under the \".value\" key. \n\n #### Declaration\n\n Objective-C \n\n - (id _Nullable)valueInExportFormat;\n\n[Properties\n----------](#/Properties)\n\n- `\n ``\n ``\n `\n\n ### [value](#/c:objc(cs)FIRDataSnapshot(py)value)\n\n `\n ` \n Returns the contents of this data snapshot as native types.\n\n Data types returned:\n - `Dictionary`\n - `Array`\n - `NSNumber`-bridgeable types, including `Bool`\n - `String`\n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly, nullable) id value;\n\n #### Return Value\n\n The data as a native object.\n- `\n ``\n ``\n `\n\n ### [childrenCount](#/c:objc(cs)FIRDataSnapshot(py)childrenCount)\n\n `\n ` \n Gets the number of children for this DataSnapshot. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) NSUInteger childrenCount;\n\n #### Return Value\n\n An integer indicating the number of children.\n- `\n ``\n ``\n `\n\n ### [ref](#/c:objc(cs)FIRDataSnapshot(py)ref)\n\n `\n ` \n Gets a DatabaseReference for the location that this data came from. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) ../Classes/FIRDatabaseReference.html *_Nonnull ref;\n\n #### Return Value\n\n A DatabaseReference instance for the location of this data.\n- `\n ``\n ``\n `\n\n ### [key](#/c:objc(cs)FIRDataSnapshot(py)key)\n\n `\n ` \n The key of the location that generated this DataSnapshot. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) NSString *_Nonnull key;\n\n #### Return Value\n\n A `String` containing the key for the location of this\n DataSnapshot.\n- `\n ``\n ``\n `\n\n ### [children](#/c:objc(cs)FIRDataSnapshot(py)children)\n\n `\n ` \n An iterator for snapshots of the child nodes in this snapshot. \n\n for var child in snapshot.children {\n // ...\n }\n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) NSEnumerator\u003cFIRDataSnapshot *\u003e *_Nonnull children;\n\n #### Return Value\n\n An NSEnumerator of the children.\n- `\n ``\n ``\n `\n\n ### [priority](#/c:objc(cs)FIRDataSnapshot(py)priority)\n\n `\n ` \n The priority of the data in this DataSnapshot. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly, nullable) id priority;\n\n #### Return Value\n\n The priority as a `String`, or `nil` if no priority was set."]]