Inherits from NMCore : NSObject
Declared in NMUser.h
NMUser.m

Overview

The NMUser class is used to perform regarding operations in order to create a user management system in the application. Registering, updating and logging users are the operations performed over NMUser instances. All registered users are stored over cloud.

Tasks

Properties

activeLoginType

Enum type which indicates how the user login into the application.

@property (nonatomic, readonly, assign) NMLoginType activeLoginType

Discussion

Enum type which indicates how the user login into the application.

Warning: Available enum options for LoginType

NMLoginTypeNone, user does not login yet.

NMLoginTypeFacebook, user logins with a Facebook account.

NMLoginTypeTwitter, user logins with a Twitter account.

NMLoginTypeEmail, user logins with an email account.

NMLoginTypeGuest, user logins as guest.

Declared In

NMUser.h

customDictionary

Custom key-value pairs assigned to the registered user.

@property (nonatomic, strong) NSMutableDictionary *customDictionary

Discussion

Custom key-value pairs assigned to the registered user.

The value on the user is overridden every time newly-created customDictionary property is sent with any request.

Declared In

NMUser.h

email

Email address of the registered user.

@property (nonatomic, strong) NSString *email

Discussion

Email address of the registered user.

Declared In

NMUser.h

facebookId

Identifier given by Facebook when logging on the user with a Facebook account.

@property (nonatomic, strong) NSString *facebookId

Discussion

Identifier given by Facebook when logging on the user with a Facebook account.

Declared In

NMUser.h

isGeneratedMail

The boolean value which shows whether the email of the user is generated by the system or not.

@property BOOL isGeneratedMail

Discussion

The boolean value which shows whether the email of the user is generated by the system or not.

Declared In

NMUser.h

isNewUser

The boolean value which shows whether the user is a newly-registered or not.

@property BOOL isNewUser

Discussion

The boolean value which shows whether the user is a newly-registered or not.

Declared In

NMUser.h

name

Name of the registered user.

@property (nonatomic, strong) NSString *name

Discussion

Name of the registered user.

Declared In

NMUser.h

nickname

Nickname of the registered user.

@property (nonatomic, strong) NSString *nickname

Discussion

Nickname of the registered user.

Declared In

NMUser.h

password

Password of the registered user.

@property (nonatomic, strong) NSString *password

Discussion

Password of the registered user.

Declared In

NMUser.h

surname

Surname of the registered user.

@property (nonatomic, strong) NSString *surname

Discussion

Surname of the registered user.

Declared In

NMUser.h

twitterUserName

Identifier given by Twitter when logging on the user with a Twitter account.

@property (nonatomic, strong) NSString *twitterUserName

Discussion

Identifier given by Twitter when logging on the user with a Twitter account.

Declared In

NMUser.h

Class Methods

activateUserWithEmail:andError:

Activates login operation for a registered user.

+ (BOOL)activateUserWithEmail:(NSString *)email andError:(NSError **)error

Parameters

email

Email address of the registered user.

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the user is activated succesfully. Returns NO if an error occurs.

Discussion

Activates login operation for a registered user.

When a newly-created user is registered to the application, it is activated automatically.

Declared In

NMUser.h

deactivateUserWithEmail:andError:

Deactivates login operation for a registered user.

+ (BOOL)deactivateUserWithEmail:(NSString *)email andError:(NSError **)error

Parameters

email

Email address of the registered user.

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the user is deactivated succesfully. Returns NO if an error occurs.

Discussion

Deactivates login operation for a registered user.

Declared In

NMUser.h

getCurrentUser

Returns the current logged user.

+ (NMUser *)getCurrentUser

Return Value

Current logged user in the application. Returns nil if there is no logged user.

Discussion

Returns the current logged user.

Declared In

NMUser.h

loginAsGuestInBackgroundWithCompletionHandler:

Logs on a guest user for the application on the background thread. Guest user means a user with no property set.

+ (void)loginAsGuestInBackgroundWithCompletionHandler:(void ( ^ ) ( NMUser *user , NSError *error ))handler

Parameters

handler

The block to execute when the login of the user is completed.

Discussion

Logs on a guest user for the application on the background thread. Guest user means a user with no property set.

The logged user is saved in cache until calling logout method. As background methods does not block your main thread, it is recommended to use loginAsGuestInBackgroundWithCompletionHandler: over loginAsGuestWithError:.

Declared In

NMUser.h

loginAsGuestWithError:

Logs on a guest user for the application. Guest user means a user with no property set.

+ (NMUser *)loginAsGuestWithError:(NSError **)error

Parameters

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

Logged guest NMUser object if login is completed succesfully. Returns NO if an error occurs.

Discussion

Logs on a guest user for the application. Guest user means a user with no property set.

The logged user is saved in cache until calling logout method.

Declared In

NMUser.h

loginInBackgroundWithEmail:password:completionHandler:

Logs on a user with email for the application on the background thread.

+ (void)loginInBackgroundWithEmail:(NSString *)email password:(NSString *)password completionHandler:(void ( ^ ) ( NMUser *user , NSError *error ))handler

Parameters

email

Email address of the registered user.

password

Password of the registered user.

handler

The block to execute when the login of the user is completed.

Discussion

Logs on a user with email for the application on the background thread.

The logged user is saved in cache until calling logout method. As background methods does not block your main thread, it is recommended to use loginInBackgroundWithEmail:password:completionHandler: over loginWithEmail:password:error:.

Declared In

NMUser.h

loginWithEmail:password:error:

Logs on a user with email for the application.

+ (NMUser *)loginWithEmail:(NSString *)email password:(NSString *)password error:(NSError **)error

Parameters

email

Email address of the registered user.

password

Password of the registered user.

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

Logged NMUser object if login is completed succesfully. Returns NO if an error occurs.

Discussion

Logs on a user with email for the application.

The logged user is saved in cache until calling logout method.

Declared In

NMUser.h

logout

Logs the user out of the application.

+ (void)logout

Discussion

Logs the user out of the application.

Calling this method removes the current user from the cache.

Declared In

NMUser.h

Instance Methods

registerInBackgroundWithCompletionHandler:

Registers a new user to the application on the background thread. Email, password and nickname properties must be set on the user because they are required fields; otherwise, name, surname and customDictionary properties are optional.

- (void)registerInBackgroundWithCompletionHandler:(void ( ^ ) ( NSError *error ))handler

Parameters

handler

The block to execute when the registration of the user is completed.

Discussion

Registers a new user to the application on the background thread. Email, password and nickname properties must be set on the user because they are required fields; otherwise, name, surname and customDictionary properties are optional.

Rest of properties except the ones mentioned above should not be set. They will be set automatically after calling the relevant method. As background methods does not block your main thread, it is recommended to use registerInBackgroundWithCompletionHandler: over registerWithError:.

Declared In

NMUser.h

registerWithError:

Registers a new user to the application. Email, password and nickname properties must be set on the user because they are required fields; otherwise, name, surname and customDictionary properties are optional.

- (BOOL)registerWithError:(NSError **)error

Parameters

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the user is registered succesfully. Returns NO if an error occurs.

Discussion

Registers a new user to the application. Email, password and nickname properties must be set on the user because they are required fields; otherwise, name, surname and customDictionary properties are optional.

Rest of properties except the ones mentioned above should not be set. They will be set automatically after calling the relevant method.

Declared In

NMUser.h

updateInBackgroundWithCompletionHandler:

Updates a registered user on the background thread. Only the properties on the caller NMUser object are updated. All properties except email can be updated.

- (void)updateInBackgroundWithCompletionHandler:(void ( ^ ) ( NSError *error ))handler

Parameters

handler

The block to execute when the update of the user is completed.

Discussion

Updates a registered user on the background thread. Only the properties on the caller NMUser object are updated. All properties except email can be updated.

As background methods does not block your main thread, it is recommended to use updateInBackgroundWithCompletionHandler: over updateWithError: or update:.

Declared In

NMUser.h

updateWithError:

Updates a registered user. Only the properties on the caller NMUser object are updated. All properties except email can be updated.

- (BOOL)updateWithError:(NSError **)error

Parameters

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the user is updated succesfully. Returns NO if an error occurs.

Discussion

Updates a registered user. Only the properties on the caller NMUser object are updated. All properties except email can be updated.

Declared In

NMUser.h