Stay organized with collections
Save and categorize content based on your preferences.
FIRDocumentSnapshot
@interfaceFIRDocumentSnapshot:NSObject
A DocumentSnapshot contains data read from a document in your Firestore database. The data
can be extracted with the data property or by using subscript syntax to access a specific
field.
For a DocumentSnapshot that points to a non-existing document, any data access will return
nil. You can use the exists property to explicitly verify a documents existence.
Retrieves all fields in the document as a Dictionary. Returns nil if the document doesn’t
exist.
Server-provided timestamps that have not yet been set to their final value will be returned as
NSNull. You can use the data(with:) method to configure this behavior.
Declaration
Objective-C
-(nullableNSDictionary<NSString*,id>*)data;
Return Value
A Dictionary containing all fields in the document or nil if the document doesn’t
exist.
Retrieves a specific field from the document. Returns nil if the document or the field doesn’t
exist.
The timestamps that have not yet been set to their final value will be returned as NSNull. You
can use get(_:serverTimestampBehavior:) to configure this behavior.
Declaration
Objective-C
-(nullableid)valueForField:(nonnullid)field;
Parameters
field
The field to retrieve.
Return Value
The value contained in the field or nil if the document or field doesn’t exist.
Retrieves a specific field from the document. Returns nil if the document or the field doesn’t
exist.
The timestamps that have not yet been set to their final value will be returned as NSNull. You
can use get(_:serverTimestampBehavior:) to configure this behavior.
[[["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,["# FirebaseFirestore Framework Reference\n\nFIRDocumentSnapshot\n===================\n\n\n @interface FIRDocumentSnapshot : NSObject\n\nA `DocumentSnapshot` contains data read from a document in your Firestore database. The data\ncan be extracted with the `data` property or by using subscript syntax to access a specific\nfield.\n\nFor a `DocumentSnapshot` that points to a non-existing document, any data access will return\n`nil`. You can use the `exists` property to explicitly verify a documents existence.\n- `\n ``\n ``\n `\n\n ### [exists](#/c:objc(cs)FIRDocumentSnapshot(py)exists)\n\n `\n ` \n True if the document exists. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) BOOL exists;\n\n- `\n ``\n ``\n `\n\n ### [reference](#/c:objc(cs)FIRDocumentSnapshot(py)reference)\n\n `\n ` \n A `DocumentReference` to the document location. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) ../Classes/FIRDocumentReference.html *_Nonnull reference;\n\n- `\n ``\n ``\n `\n\n ### [documentID](#/c:objc(cs)FIRDocumentSnapshot(py)documentID)\n\n `\n ` \n The ID of the document for which this `DocumentSnapshot` contains data. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, copy, readonly) NSString *_Nonnull documentID;\n\n- `\n ``\n ``\n `\n\n ### [metadata](#/c:objc(cs)FIRDocumentSnapshot(py)metadata)\n\n `\n ` \n Metadata about this snapshot concerning its source and if it has local modifications. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, strong, readonly) ../Classes/FIRSnapshotMetadata.html *_Nonnull metadata;\n\n- `\n ``\n ``\n `\n\n ### [-data](#/c:objc(cs)FIRDocumentSnapshot(im)data)\n\n `\n ` \n Retrieves all fields in the document as a `Dictionary`. Returns `nil` if the document doesn't\n exist.\n\n Server-provided timestamps that have not yet been set to their final value will be returned as\n `NSNull`. You can use the `data(with:)` method to configure this behavior. \n\n #### Declaration\n\n Objective-C \n\n - (nullable NSDictionary\u003cNSString *, id\u003e *)data;\n\n #### Return Value\n\n A `Dictionary` containing all fields in the document or `nil` if the document doesn't\n exist.\n- `\n ``\n ``\n `\n\n ### [-dataWithServerTimestampBehavior:](#/c:objc(cs)FIRDocumentSnapshot(im)dataWithServerTimestampBehavior:)\n\n `\n ` \n Retrieves all fields in the document as a `Dictionary`. Returns `nil` if the document doesn't\n exist. \n\n #### Declaration\n\n Objective-C \n\n - (nullable NSDictionary\u003cNSString *, id\u003e *)dataWithServerTimestampBehavior:\n (../Enums/FIRServerTimestampBehavior.html)serverTimestampBehavior;\n\n #### Parameters\n\n |---------------------------------|------------------------------------------------------------------------------------------------------------------|\n | ` `*serverTimestampBehavior*` ` | Configures how server timestamps that have not yet been set to their final value are returned from the snapshot. |\n\n #### Return Value\n\n A `Dictionary` containing all fields in the document or `nil` if the document doesn't\n exist.\n- `\n ``\n ``\n `\n\n ### [-valueForField:](#/c:objc(cs)FIRDocumentSnapshot(im)valueForField:)\n\n `\n ` \n Retrieves a specific field from the document. Returns `nil` if the document or the field doesn't\n exist.\n\n The timestamps that have not yet been set to their final value will be returned as `NSNull`. You\n can use `get(_:serverTimestampBehavior:)` to configure this behavior. \n\n #### Declaration\n\n Objective-C \n\n - (nullable id)valueForField:(nonnull id)field;\n\n #### Parameters\n\n |---------------|------------------------|\n | ` `*field*` ` | The field to retrieve. |\n\n #### Return Value\n\n The value contained in the field or `nil` if the document or field doesn't exist.\n- `\n ``\n ``\n `\n\n ### [-valueForField:serverTimestampBehavior:](#/c:objc(cs)FIRDocumentSnapshot(im)valueForField:serverTimestampBehavior:)\n\n `\n ` \n Retrieves a specific field from the document. Returns `nil` if the document or the field doesn't\n exist.\n\n The timestamps that have not yet been set to their final value will be returned as `NSNull`. You\n can use `get(_:serverTimestampBehavior:)` to configure this behavior. \n\n #### Declaration\n\n Objective-C \n\n - (nullable id)valueForField:(nonnull id)field\n serverTimestampBehavior:\n (../Enums/FIRServerTimestampBehavior.html)serverTimestampBehavior;\n\n #### Parameters\n\n |---------------------------------|------------------------------------------------------------------------------------------------------------------|\n | ` `*field*` ` | The field to retrieve. |\n | ` `*serverTimestampBehavior*` ` | Configures how server timestamps that have not yet been set to their final value are returned from the snapshot. |\n\n #### Return Value\n\n The value contained in the field or `nil` if the document or field doesn't exist.\n- `\n ``\n ``\n `\n\n ### [-objectForKeyedSubscript:](#/c:objc(cs)FIRDocumentSnapshot(im)objectForKeyedSubscript:)\n\n `\n ` \n Retrieves a specific field from the document. \n\n #### Declaration\n\n Objective-C \n\n - (nullable id)objectForKeyedSubscript:(nonnull id)key;\n\n #### Parameters\n\n |-------------|------------------------|\n | ` `*key*` ` | The field to retrieve. |\n\n #### Return Value\n\n The value contained in the field or `nil` if the document or field doesn't exist."]]