WCDataSnapshot

@interface WCDataSnapshot : NSObject

A WCDataSnapshot is used to read data from a specific Webcom location.

Callbacks passed to onEventType(_:withCallback:) and onceEventType(_:withCallback:) methods from WCQuery are called with an instance of WCDataSnapshot as the first parameter.

To get the data, use the value property.

To update the data, use the set(_:), update(_:), push(_:) or remove(_:) methods from WCWebcom.

Instances of WCDataSnapshot are immutables.

  • Retrieves the value object with priority data for this data snapshot.

    Declaration

    Objective-C

    - (nullable id)exportVal;

    Return Value

    The value object with priority data.

  • Indicates if the data snapshot has at least one child.

    true if the data snapshot has any children, false it has no children.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasChildren;
  • The name of the Webcom location targeted by this data snapshot.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *name;
  • The number of children for this data snapshot.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSNumber *numChildren;
  • ref

    The Webcom reference for the location of this data snapshot.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) WCWebcom *ref;
  • The value object for this data snapshot.

    Value can be one of the following types:

    • NSDictionary
    • NSArray
    • NSNumber
    • NSString

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) id value;
  • Retrieves the child data snapshot corresponding to the specified relative path.

    Declaration

    Objective-C

    - (nullable WCDataSnapshot *)child:(nonnull NSString *)childPathString;

    Parameters

    childPathString

    The path of the child relative to the data snapshot. For instance friends or friends/fred.

    Return Value

    The child data snapshot for the location.

  • Executes a given block using each children of the data snapshot.

    Declaration

    Objective-C

    - (BOOL)forEach:(nonnull BOOL (^)(WCDataSnapshot *_Nonnull))action;

    Parameters

    action

    The block to apply to the children. The child is passed as the parameter of this block. You can return true to stop the loop.

    Return Value

    true if the loop was stopped intentionally, false otherwise.

  • Indicates if a child data snapshot exists at the specified relative path.

    Declaration

    Objective-C

    - (BOOL)hasChild:(nonnull NSString *)childPathString;