FDataSnapshot Class Reference

Inherits from NSObject
Declared in FDataSnapshot.h

Overview

An FDataSnapshot contains data from a Firebase database. Any time you read Firebase data, you receive the data as an FDataSnapshot.

FDataSnapshots are passed to the blocks you attach with observeEventType:withBlock: or observeSingleEvent:withBlock:. They are efficiently-generated immutable copies of the data at a Firebase database. They can’t be modified and will never change. To modify data at a location, use a Firebase reference (e.g. with setValue:).

Navigating and inspecting a snapshot

– childSnapshotForPath:

Get an FDataSnapshot 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 FDataSnapshot is returned.

- (FDataSnapshot *)childSnapshotForPath:(NSString *)childPathString

Parameters

childPathString

A relative path to the location of child data.

Return Value

The FDataSnapshot for the child location.

Discussion

Get an FDataSnapshot 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 FDataSnapshot is returned.

Declared In

FDataSnapshot.h

– hasChild:

Return YES if the specified child exists.

- (BOOL)hasChild:(NSString *)childPathString

Parameters

childPathString

A relative path to the location of a potential child.

Return Value

YES if data exists at the specified childPathString, else false.

Discussion

Return YES if the specified child exists.

Declared In

FDataSnapshot.h

– hasChildren

Return YES if the DataSnapshot has any children.

- (BOOL)hasChildren

Return Value

YES if this snapshot has any children, else NO.

Discussion

Return YES if the DataSnapshot has any children.

Declared In

FDataSnapshot.h

– exists

Return YES if the DataSnapshot contains a non-null value.

- (BOOL)exists

Return Value

YES if this snapshot contains a non-null value, otherwise NO.

Discussion

Return YES if the DataSnapshot contains a non-null value.

Declared In

FDataSnapshot.h

Data export

– valueInExportFormat

Returns the raw value at this location, coupled with any metadata, such as priority.

- (id)valueInExportFormat

Discussion

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.

Declared In

FDataSnapshot.h

Properties

  value

Returns the contents of this data snapshot as native types.

@property (strong, readonly, nonatomic) id value

Return Value

The data as a native object.

Discussion

Returns the contents of this data snapshot as native types.

Data types returned: * NSDictionary * NSArray * NSNumber (also includes booleans) * NSString

Declared In

FDataSnapshot.h

  childrenCount

Get the number of children for this DataSnapshot.

@property (readonly, nonatomic) NSUInteger childrenCount

Return Value

An integer indicating the number of children.

Discussion

Get the number of children for this DataSnapshot.

Declared In

FDataSnapshot.h

  ref

Get a Firebase reference for the location that this data came from

@property (nonatomic, readonly, strong) Firebase *ref

Return Value

A Firebase instance for the location of this data

Discussion

Get a Firebase reference for the location that this data came from

Declared In

FDataSnapshot.h

  key

The name of the location that generated this FDataSnapshot.

@property (strong, readonly, nonatomic) NSString *key

Return Value

An NSString containing the key for the location of this FDataSnapshot.

Discussion

The name of the location that generated this FDataSnapshot.

Declared In

FDataSnapshot.h

  children

An iterator for snapshots of the child nodes in this snapshot. You can use the native for..in syntax:

@property (strong, readonly, nonatomic) NSEnumerator *children

Return Value

An NSEnumerator of the children

Discussion

An iterator for snapshots of the child nodes in this snapshot. You can use the native for..in syntax:

for (FDataSnapshot* child in snapshot.children) { … }

Declared In

FDataSnapshot.h

  priority

The priority of the data in this FDataSnapshot.

@property (strong, readonly, nonatomic) id priority

Return Value

The priority as a string, or nil if no priority was set.

Discussion

The priority of the data in this FDataSnapshot.

Declared In

FDataSnapshot.h