MFUser Class Reference

Inherits from NSObject
Declared in MFUser.h
MFUser.m

Overview

The MFUser class is a local representation of a user persisted to the Mesosfer Data. This class is an extended of a MFData, and retains the same functionality of a MFData, but also extends it with various user specific methods, like register, login, and validation uniqueness.

  email

Specifies a email address for user that used for login credential.

@property (strong, nonatomic, nullable) NSString *email

Declared In

MFUser.h

  password

Specifies a secure password for user that used for login credential.

@property (strong, nonatomic, nullable) NSString *password

Declared In

MFUser.h

  firstname

Specifies first name of user.

@property (strong, nonatomic, nullable) NSString *firstname

Declared In

MFUser.h

  lastname

Specifies last name of user.

@property (strong, nonatomic, nullable) NSString *lastname

Declared In

MFUser.h

  data

Specifies all key and value pairs of user data.

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

Declared In

MFUser.h

  objectId

Specifies a unique id of a user.

@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

MFUser.h

  createdAt

Specifies a created timestamp of a user.

@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

MFUser.h

  updatedAt

Specifies a last updated timestamp of a user.

@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

MFUser.h

  schema

Specifies a MFDataSchema object of a user.

@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

MFUser.h

+ user

Creates a new user object.

+ (nonnull instancetype)user

Return Value

A new user object.

See Also

Declared In

MFUser.h

+ currentUser

Gets the currently logged in user from disk and returns an instance of it.

+ (nullable instancetype)currentUser

Return Value

Returns a MFUser that is the currently logged in user. If there is none, returns nil.

Declared In

MFUser.h

+ query

Creates a new MFQuery instance for querying MFUser objects.

+ (nonnull MFQuery *)query

Return Value

A new MFQuery instance.

See Also

Declared In

MFUser.h

– dictionary

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

- (nullable NSDictionary *)dictionary

Return Value

The dictionary of all key and value pair object.

Declared In

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.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

MFUser.h

– removeObjectForKey:

Unsets a key on the object.

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

Parameters

key

The key.

Declared In

MFUser.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

MFUser.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

MFUser.h

– registerAsyncWithBlock:

Register new user asynchronously.

- (void)registerAsyncWithBlock:(nullable MFBooleanResultBlock)block

Parameters

block

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

Discussion

This will also enforce that the email address isn’t already taken.

Warning: Make sure that password and email address are set before calling this method.

Declared In

MFUser.h

+ logInAsyncWithEmail:password:block:

Makes an asynchronous request to log in a user with specified credentials.

+ (void)logInAsyncWithEmail:(nonnull NSString *)email password:(nonnull NSString *)password block:(nullable MFUserResultBlock)block

Parameters

email

The email address of the user.

password

The password of the user.

block

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

Discussion

Returns an instance of the successfully logged in MFUser. This also caches the user locally so that calls to currentUser will use the latest logged in user.

Declared In

MFUser.h

+ logOutAsyncWithBlock:

Asynchronously logs out the currently logged in user.

+ (void)logOutAsyncWithBlock:(nullable MFUserLogoutResultBlock)block

Parameters

block

A block that will be called when logging out completes or fails.

Discussion

This will also remove the session from disk, log out of linked services and all future calls to currentUser will return nil.

Declared In

MFUser.h

– saveAsyncWithBlock:

Saves the MFUser 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

MFUser.h

– fetchAsyncWithBlock:

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

- (void)fetchAsyncWithBlock:(nullable MFUserResultBlock)block

Parameters

block

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

Discussion

Warning: Use this method only on MFUser.currentUser, cannot be used on user object found by MFQuery

Declared In

MFUser.h

– changePasswordAsyncWithOldPassword:newPassword:block:

Changes the current MFUser password on Mesosfer cloud asynchronously and executes the given callback block.

- (void)changePasswordAsyncWithOldPassword:(nonnull NSString *)oldPassword newPassword:(nonnull NSString *)newPassword block:(nullable MFBooleanResultBlock)block

Parameters

oldPassword

The old existing current user password.

newPassword

The new password to set.

block

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

Discussion

Warning: Use this method only on MFUser.currentUser, cannot be used on user object found by MFQuery

Declared In

MFUser.h