SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
SFSObject Class Reference

#import <SFSObject.h>

Inherits NSObject, and <ISFSObject>.

Instance Methods

(BOOL) - isNull:
 
(BOOL) - containsKey:
 
(void) - removeElement:
 
(NSArray *) - getKeys
 
(NSInteger) - size
 
(NSData *) - toBinary
 
(NSString *) - getDump:
 
(NSString *) - getHexDump
 
(SFSDataWrapper *) - getData:
 
(BOOL) - getBool:
 
(NSInteger) - getByte:
 
(NSInteger) - getUnsignedByte:
 
(NSInteger) - getShort:
 
(NSInteger) - getInt:
 
(NSNumber *) - getLong:
 
(NSNumber *) - getFloat:
 
(NSNumber *) - getDouble:
 
(NSString *) - getUtfString:
 
(NSArray *) - getBoolArray:
 
(NSData *) - getByteArray:
 
(NSArray *) - getUnsignedByteArray:
 
(NSArray *) - getShortArray:
 
(NSArray *) - getIntArray:
 
(NSArray *) - getLongArray:
 
(NSArray *) - getFloatArray:
 
(NSArray *) - getDoubleArray:
 
(NSArray *) - getUtfStringArray:
 
(NSString *) - getText:
 
(id< ISFSArray >) - getSFSArray:
 
(id< ISFSObject >) - getSFSObject:
 
(id) - getClass:
 
(void) - putNull:
 
(void) - putBool:value:
 
(void) - putByte:value:
 
(void) - putShort:value:
 
(void) - putInt:value:
 
(void) - putLong:value:
 
(void) - putFloat:value:
 
(void) - putDouble:value:
 
(void) - putUtfString:value:
 
(void) - putBoolArray:value:
 
(void) - putByteArray:value:
 
(void) - putShortArray:value:
 
(void) - putIntArray:value:
 
(void) - putLongArray:value:
 
(void) - putFloatArray:value:
 
(void) - putDoubleArray:value:
 
(void) - putUtfStringArray:value:
 
(void) - putText:value:
 
(void) - putSFSArray:value:
 
(void) - putSFSObject:value:
 
(void) - putClass:value:
 
(void) - put:value:
 

Class Methods

(id) + newInstance
 
(id) + newFromBinaryData:
 

Protected Attributes

NSMutableDictionary * _dataHolder
 
id< ISFSDataSerializer > _serializer
 

Detailed Description

SFSObject is used from both server and client sides to exchange data. It can be thought of a specialized Dictionary/Map object that can contain any type of data.

The advantage of using SFSObject is that you can fine tune the way your data will be transmitted over the network. For instance, a number like 100 can be transmitted as a normal integer (which takes 32 bits) but also a short (16 bit) or even a byte (8 bit)

SFSObject supports many primitive data types and related arrays of primitives. It also allows to serialize class instances and rebuild them on the Java side. This is explained in greater detail in a separate document.

NOTE: UTF-8/multi-byte strings are not supported in key names. In other words you should restrict key names to standard ASCII characters. It is also recommended to keep key names very short to save bandwidth.

More details and examples.

See also
ISFSObject
SFSArray

Method Documentation

◆ containsKey:

- (BOOL) containsKey: (NSString *)  key

Returns true if an element exists with the provided key

◆ getBool:

- (BOOL) getBool: (NSString *)  key

Get the element for the provided key as a Boolean

◆ getBoolArray:

- (NSArray *) getBoolArray: (NSString *)  key

Get the element for the provided key as an array of Booleans

◆ getByte:

- (NSInteger) getByte: (NSString *)  key

Get the element for the provided key as a signed byte (8 bit) (int in AS3)

◆ getByteArray:

- (NSData *) getByteArray: (NSString *)  key

Get the element for the provided key as a an array of byte

◆ getDouble:

- (NSNumber *) getDouble: (NSString *)  key

Get the element for the provided key as a double (Number in AS3)

◆ getDoubleArray:

- (NSArray *) getDoubleArray: (NSString *)  key

Get the element for the provided key as an array of doubles

◆ getDump:

- (NSString *) getDump: (BOOL)  format

Return a formatted dump of the object that can logged or traced in the console for debugging purposes.

Parameters
formatturns the "pretty print" on/off

◆ getFloat:

- (NSNumber *) getFloat: (NSString *)  key

Get the element for the provided key as a float (Number in AS3)

◆ getFloatArray:

- (NSArray *) getFloatArray: (NSString *)  key

Get the element for the provided key as an array of floats

◆ getHexDump

- (NSString *) getHexDump

Returns a detailed hex-dump of the object that can logged or traced in the console for debugging purposes.

◆ getInt:

- (NSInteger) getInt: (NSString *)  key

Get the element for the provided key as an int (32 bit)

◆ getIntArray:

- (NSArray *) getIntArray: (NSString *)  key

Get the element for the provided key as an array of int

◆ getKeys

- (NSArray *) getKeys

Return an array with all the keys in the SFSObject

◆ getLong:

- (NSNumber *) getLong: (NSString *)  key

Get the element for the provided key as a long int (64 bit) (Number in AS3)

◆ getLongArray:

- (NSArray *) getLongArray: (NSString *)  key

Get the element for the provided key as an array of long int

◆ getSFSArray:

- (id< ISFSArray >) getSFSArray: (NSString *)  key

Get the element for the provided key as an SFSArray

◆ getSFSObject:

- (id< ISFSObject >) getSFSObject: (NSString *)  key

Get the element for the provided key as an SFSObject

◆ getShort:

- (NSInteger) getShort: (NSString *)  key

Get the element for the provided key as a short int (16 bit) (int in AS3)

◆ getShortArray:

- (NSArray *) getShortArray: (NSString *)  key

Get the element for the provided key as an array of short int

◆ getText:

- (NSString *) getText: (NSString*)  key

Get the element for the provided key as a UTF-8 String (use with strings > 32KB, up 2GB) Requires API 1.7.x or higher

◆ getUnsignedByte:

- (NSInteger) getUnsignedByte: (NSString *)  key

Get the element for the provided key as a unsigned byte (8 bit) (int in AS3)

◆ getUnsignedByteArray:

- (NSArray *) getUnsignedByteArray: (NSString *)  key

Get the element for the provided key as a an array of integers representing each byte as unsigned values

◆ getUtfString:

- (NSString *) getUtfString: (NSString *)  key

Get the element for the provided key as a UTF-8 String (use with strings <= 32KB)

◆ getUtfStringArray:

- (NSArray *) getUtfStringArray: (NSString *)  key

Get the element for the provided key as an array of UTF-8 Strings (use with strings <= 32KBytes)

◆ isNull:

- (BOOL) isNull: (NSString *)  key

Checks if a specific element in the SFSObject is null

◆ newFromBinaryData:

+ (id) newFromBinaryData: (NSData *)  packet

Alternative static constructor that builds an SFSObject from a valid SFSObject binary representation

◆ newInstance

+ (id) newInstance

Alternative static constructor

◆ putBool:value:

- (void) putBool: (NSString *)  key
value: (BOOL)  value 

Put a Boolean value with the provided key

◆ putBoolArray:value:

- (void) putBoolArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of Booleans with the provided key

◆ putByte:value:

- (void) putByte: (NSString *)  key
value: (NSInteger)  value 

Put a byte value (8 bit) with the provided key

◆ putByteArray:value:

- (void) putByteArray: (NSString *)  key
value: (NSData *)  value 

Put an array of bytes with the provided key

◆ putDouble:value:

- (void) putDouble: (NSString *)  key
value: (NSNumber *)  value 

Put a double (64 bit) with the provided key

◆ putDoubleArray:value:

- (void) putDoubleArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of doubles with the provided key

◆ putFloat:value:

- (void) putFloat: (NSString *)  key
value: (NSNumber *)  value 

Put a float (32 bit) with the provided key

◆ putFloatArray:value:

- (void) putFloatArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of floats with the provided key

◆ putInt:value:

- (void) putInt: (NSString *)  key
value: (NSInteger)  value 

Put an int (32 bit) with the provided key

◆ putIntArray:value:

- (void) putIntArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of ints with the provided key

◆ putLong:value:

- (void) putLong: (NSString *)  key
value: (NSNumber *)  value 

Put a long int (64 bit) with the provided key

◆ putLongArray:value:

- (void) putLongArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of long ints with the provided key

◆ putSFSArray:value:

- (void) putSFSArray: (NSString *)  key
value: (id<ISFSArray>)  value 

Put an SFSArray with the provided key

See also
SFSArray

◆ putSFSObject:value:

- (void) putSFSObject: (NSString *)  key
value: (id<ISFSObject>)  value 

Put an SFSObject with the provided key

◆ putShort:value:

- (void) putShort: (NSString *)  key
value: (NSInteger)  value 

Put a short int (16 bit) with the provided key

◆ putShortArray:value:

- (void) putShortArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of short ints with the provided key

◆ putText:value:

- (void) putText: (NSString *)  key
value: (NSString*)  value 

Put an array of Strings with the provided key (use with strings > 32KB, up to 2GB) Requires API 1.7.x or higher

◆ putUtfString:value:

- (void) putUtfString: (NSString *)  key
value: (NSString *)  value 

Put a UTF-8 String with the provided key

◆ putUtfStringArray:value:

- (void) putUtfStringArray: (NSString *)  key
value: (NSArray *)  value 

Put an array of Strings with the provided key (use with strings <= 32KB)

◆ removeElement:

- (void) removeElement: (NSString *)  key

Removes an element

◆ size

- (NSInteger) size

Return the number of elements in the SFSObject

◆ toBinary

- (NSData *) toBinary

Return the binary form of the object