MFData Class Reference

Inherits from NSObject
Declared in MFData.h
MFData.m

Overview

The MFData class is a local representation of data persisted to the Mesosfer cloud. This is the main class that is used to interact with objects in your app.

  bucket

Specifies the bucket name of MFData.

@property (strong, nonatomic, readonly, nullable) NSString *bucket

Declared In

MFData.h

  data

Specifies the custom NSDictionary data of MFData.

@property (strong, nonatomic, readonly, nullable) NSDictionary *data

Declared In

MFData.h

  objectId

Specifies the unique id of MFData object.

@property (strong, nonatomic, readonly, nullable) NSString *objectId

Discussion

This field will be assigned by fetching current object that exists or by saving new user to Mesosfer cloud.

Declared In

MFData.h

  createdAt

Specifies the created timestamp of MFData object.

@property (strong, nonatomic, readonly, nullable) NSDate *createdAt

Discussion

This field will be assigned by fetching current object that exists or by saving new user to Mesosfer cloud.

Declared In

MFData.h

  updatedAt

Specifies the last updated timestamp of MFData object.

@property (strong, nonatomic, readonly, nullable) NSDate *updatedAt

Discussion

This field will be assigned by fetching current object that exists or by saving new user to Mesosfer cloud.

Declared In

MFData.h

  schema

Specifies the MFDataSchema of MFData object.

@property (strong, nonatomic, readonly, nullable) MFDataSchema *schema

Discussion

This field will be assigned by fetching current object that exists or by saving new user to Mesosfer cloud.

Declared In

MFData.h

+ dataWithBucket:NS_SWIFT_NAME:

Creates a new MFData with a bucket name.

+ (nonnull instancetype)dataWithBucket:(nonnull NSString *)bucket NS_SWIFT_NAME

Parameters

bucket

A bucket name can be any alphanumeric string that begins with a letter. It represents an object in your app, like a ‘User’ or a ‘Document’.

Return Value

the object that is instantiated with the given bucket name.

Declared In

MFData.h

+ dataWithSchema:NS_SWIFT_NAME:

Creates a new MFData with a MFDataSchema object.

+ (nonnull instancetype)dataWithSchema:(nonnull MFDataSchema *)schema NS_SWIFT_NAME

Parameters

schema

A MFDataSchema object of a bucket.

Return Value

the object that is instantiated with the given MFDataSchema object.

Declared In

MFData.h

+ dataWithObjectId:NS_SWIFT_NAME:

Creates a reference to an existing MFData for use in creating associations between MFDatas.

+ (nonnull instancetype)dataWithObjectId:(nonnull NSString *)objectId NS_SWIFT_NAME

Parameters

objectId

The object id for the referenced MFData object.

Return Value

A MFData instance without data.

Discussion

Warning: You need to call MFData.fetchAsyncWithBlock: to fetch object from Mesosfer cloud.

Declared In

MFData.h

+ queryWithBucket:

Creates a new MFQuery instance for querying MData objects using bucket name.

+ (nonnull MFQuery *)queryWithBucket:(nonnull NSString *)bucket

Parameters

bucket

The bucket name.

Return Value

A new MFQuery instance.

Declared In

MFData.h

+ queryWithSchema:

Creates a new MFQuery instance for querying MFData objects using MFDataSchema object.

+ (nonnull MFQuery *)queryWithSchema:(nonnull MFDataSchema *)dataSchema

Parameters

dataSchema

The MFDataSchema object.

Return Value

A new MFQuery instance.

Declared In

MFData.h

– dictionary

Gets all key and value pair of MFData object in a dictionary.

- (nullable NSDictionary *)dictionary

Return Value

The dictionary of all key and value pair object.

Declared In

MFData.h

– objectForKey:

Returns the value associated with a given key.

- (nullable id)objectForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– objectForKeyedSubscript:

Returns the value associated with a given key.

- (nullable id)objectForKeyedSubscript:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Discussion

This method enables usage of literal syntax on MFUser. E.g. NSString *value = user[@"key"];

See Also

Declared In

MFData.h

– stringForKey:

Returns the NSString value associated with a given key.

- (nullable NSString *)stringForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– numberForKey:

Returns the NSNumber value associated with a given key.

- (nullable NSNumber *)numberForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– doubleForKey:

Returns the double value associated with a given key if it exists and is a double or can be coerced to a double, or NAN otherwise.

- (double)doubleForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– integerForKey:

Returns the int value associated with a given key if it exists and is an int or can be coerced to an int, or 0 otherwise.

- (int)integerForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– booleanForKey:

Returns the BOOL value associated with a given key.

- (BOOL)booleanForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– dateForKey:

Returns the NSDate value associated with a given key if it exists and is a NSDate or can be coerced to a NSDate, or nil otherwise.

- (nullable NSDate *)dateForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– dictionaryForKey:

Returns the NSDictionary value associated with a given key.

- (nullable NSDictionary *)dictionaryForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– arrayForKey:

Returns the NSArray value associated with a given key.

- (nullable NSArray *)arrayForKey:(nonnull NSString *)key

Parameters

key

The key for which to return the corresponding value.

Declared In

MFData.h

– removeObjectForKey:

Unsets a key on the object.

- (void)removeObjectForKey:(nonnull NSString *)key

Parameters

key

The key.

Declared In

MFData.h

– setObject:forKey:

Sets the object associated with a given key.

- (void)setObject:(nonnull id)object forKey:(nonnull NSString *)key

Parameters

object

The object for key. A strong reference to the object is maintained by MFUser. Raises an NSInvalidArgumentException if object is nil. If you need to represent a nil value - use NSNull.

key

The key for object. Raises an NSInvalidArgumentException if key is nil.

Declared In

MFData.h

– setObject:forKeyedSubscript:

Returns the value associated with a given key.

- (void)setObject:(nonnull id)object forKeyedSubscript:(nonnull NSString *)key

Parameters

object

The object for key. A strong reference to the object is maintained by MFUser. Raises an NSInvalidArgumentException if object is nil. If you need to represent a nil value - use NSNull.

key

The key for object. Raises an NSInvalidArgumentException if key is nil.

Discussion

This method enables usage of literal syntax on MFUser. E.g. user[@"key"] = @"value";

Declared In

MFData.h

– incrementKey:

Increments the given key by 1.

- (nonnull instancetype)incrementKey:(nonnull NSString *)key

Parameters

key

The key.

Return Value

The same instance of MFData as the receiver. This allows method chaining.

Declared In

MFData.h

– incrementKey:byAmount:

Increments the given key by a number.

- (nonnull instancetype)incrementKey:(nonnull NSString *)key byAmount:(nonnull NSNumber *)amount

Parameters

key

The key.

amount

The amount to increment.

Return Value

The same instance of MFData as the receiver. This allows method chaining.

Declared In

MFData.h

– fetchAsyncWithBlock:

Fetch the current MFData data from Mesosfer cloud asynchronously and executes the given callback block.

- (void)fetchAsyncWithBlock:(nullable MFDataResultBlock)block

Parameters

block

The block to execute. It shoud have the following argument signature: ^(MFData *data, NSError *error).

Declared In

MFData.h

– saveAsyncWithBlock:

Saves the MFData asynchronously and executes the given callback block.

- (void)saveAsyncWithBlock:(nullable MFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

MFData.h

– deleteAsyncWithBlock:

Delete the MFData object in Mesosfer cloud asynchronously and executes the given callback block.

- (void)deleteAsyncWithBlock:(nullable MFBooleanResultBlock)block

Parameters

block

The block to execute. It should have the following argument signature: ^(BOOL succeeded, NSError *error).

Declared In

MFData.h