FIRDocumentSnapshot


@interface FIRDocumentSnapshot : NSObject

A FIRDocumentSnapshot 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.

  • Declaration

    Objective-C

    - (nonnull instancetype)init;
  • True if the document exists.

    Declaration

    Swift

    var exists: Bool { get }

    Objective-C

    @property (readonly, assign, nonatomic) BOOL exists;
  • A FIRDocumentReference to the document location.

    Declaration

    Swift

    var reference: FIRDocumentReference { get }

    Objective-C

    @property (readonly, strong, nonatomic) FIRDocumentReference *_Nonnull reference;
  • The ID of the document for which this FIRDocumentSnapshot contains data.

    Declaration

    Swift

    var documentID: String { get }

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull documentID;
  • Metadata about this snapshot concerning its source and if it has local modifications.

    Declaration

    Swift

    var metadata: FIRSnapshotMetadata { get }

    Objective-C

    @property (readonly, strong, nonatomic) FIRSnapshotMetadata *_Nonnull metadata;
  • Retrieves all fields in the document as an NSDictionary.

    Declaration

    Swift

    func data() -> [String : Any]

    Objective-C

    - (nonnull NSDictionary<NSString *, id> *)data;

    Return Value

    An NSDictionary containing all fields in the document.

  • Retrieves a specific field from the document.

    Declaration

    Swift

    subscript(key: Any) -> Any? { get }

    Objective-C

    - (nullable id)objectForKeyedSubscript:(nonnull id)key;

    Parameters

    key

    The field to retrieve.

    Return Value

    The value contained in the field or nil if the field doesn’t exist.