Inherits from BaseVariable : NSObject
Conforms to UserVariable
Declared in SFSUserVariable.h
SFSUserVariable.m

Overview

The SFSUserVariable object represents a SmartFoxServer User Variable entity on the client. It is a custom value attached to a User object that gets automatically synchronized between client and server on every change.

User Variables are particularly useful to store custom user data that must be “visible” to the other users, such as a profile, a score, a status message, etc. User Variables can be set by means of the SetUserVariablesRequest request; they support the following data types (also nested): Boolean, int, Number, String, SFSObject, SFSArray. A User Variable can also be null.

Private UserVariables are available since SFS2X 2.12 with client API 1.7 and they allow to limit the visibility of variables marked as private to the owner only. In other words UserVariables marked as private are not sent to other users in the same Room.

See User, SetUserVariablesRequest

Class Methods

privateVariableWithName:value:

Creates a new private User Variable. Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner’s client application.

+ (id<UserVariable>)privateVariableWithName:(NSString *)name value:(id)value

Parameters

name

The name of the User Variable

value

The value of the User Variable

See

Discussion

Creates a new private User Variable. Private User Variables are not broadcast to other users: they are only visible on the server side and in the owner’s client application.

Declared In

SFSUserVariable.h

variableWithName:value:

the name of the variable

+ (id)variableWithName:(NSString *)name value:(id)value

Parameters

name

the name of the variable

value

the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

Declared In

SFSUserVariable.h

variableWithName:value:type:

the name of the variable

+ (id)variableWithName:(NSString *)name value:(id)value type:(NSInteger)type

Parameters

name

the name of the variable

value

the variable value ( can be BOOL, Integer, Double, String, SFSObject, SFSArray )

type

(optional -1) it’s usually not necessary to pass this parameter as the variable value is auto-detected

Declared In

SFSUserVariable.h

Instance Methods

isPrivate

Indicates whether this User Variable is private or not. A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

- (BOOL)isPrivate

Discussion

Indicates whether this User Variable is private or not. A private User Variable is visible only to its owner; any changes made to the variable will be transmitted to the owner only.

NOTE: setting the private property manually on an existing User Variable returned by the API has no effect on the server and can disrupt the API functioning. This flag can be set when the User Variable object is created by the developer only (using the new keyword).

Declared In

SFSUserVariable.h