FirebaseFirestore Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
FIRDocumentSnapshot
@interface FIRDocumentSnapshot : 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.
-
True if the document exists.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL exists;
-
A DocumentReference
to the document location.
-
The ID of the document for which this DocumentSnapshot
contains data.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull documentID;
-
Metadata about this snapshot concerning its source and if it has local modifications.
-
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
- (nullable NSDictionary<NSString *, id> *)data;
Return Value
A Dictionary
containing all fields in the document or nil
if the document doesn’t
exist.
-
Retrieves all fields in the document as a Dictionary
. Returns nil
if the document doesn’t
exist.
Declaration
Objective-C
- (nullable NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior:
(FIRServerTimestampBehavior)serverTimestampBehavior;
Parameters
serverTimestampBehavior
|
Configures how server timestamps that have not yet been set to
their final value are returned from the snapshot.
|
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
- (nullable id)valueForField:(nonnull id)field;
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.
Declaration
Objective-C
- (nullable id)valueForField:(nonnull id)field
serverTimestampBehavior:
(FIRServerTimestampBehavior)serverTimestampBehavior;
Parameters
field
|
|
serverTimestampBehavior
|
Configures how server timestamps that have not yet been set to
their final value are returned from the snapshot.
|
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.
Declaration
Objective-C
- (nullable id)objectForKeyedSubscript:(nonnull id)key;
Return Value
The value contained in the field or nil
if the document or field doesn’t exist.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-11 UTC.
[null,null,["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."]]