SFS2X Objective-C API
1.7.13
iOS / macOS / tvOS
|
#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 |
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.
- (BOOL) containsKey: | (NSString *) | key |
Returns true if an element exists with the provided key
- (BOOL) getBool: | (NSString *) | key |
Get the element for the provided key as a Boolean
- (NSArray *) getBoolArray: | (NSString *) | key |
Get the element for the provided key as an array of Booleans
- (NSInteger) getByte: | (NSString *) | key |
Get the element for the provided key as a signed byte (8 bit) (int in AS3)
- (NSData *) getByteArray: | (NSString *) | key |
Get the element for the provided key as a an array of byte
- (NSNumber *) getDouble: | (NSString *) | key |
Get the element for the provided key as a double (Number in AS3)
- (NSArray *) getDoubleArray: | (NSString *) | key |
Get the element for the provided key as an array of doubles
- (NSString *) getDump: | (BOOL) | format |
Return a formatted dump of the object that can logged or traced in the console for debugging purposes.
format | turns the "pretty print" on/off |
- (NSNumber *) getFloat: | (NSString *) | key |
Get the element for the provided key as a float (Number in AS3)
- (NSArray *) getFloatArray: | (NSString *) | key |
Get the element for the provided key as an array of floats
- (NSString *) getHexDump |
Returns a detailed hex-dump of the object that can logged or traced in the console for debugging purposes.
- (NSInteger) getInt: | (NSString *) | key |
Get the element for the provided key as an int (32 bit)
- (NSArray *) getIntArray: | (NSString *) | key |
Get the element for the provided key as an array of int
- (NSArray *) getKeys |
Return an array with all the keys in the SFSObject
- (NSNumber *) getLong: | (NSString *) | key |
Get the element for the provided key as a long int (64 bit) (Number in AS3)
- (NSArray *) getLongArray: | (NSString *) | key |
Get the element for the provided key as an array of long int
- (id< ISFSArray >) getSFSArray: | (NSString *) | key |
Get the element for the provided key as an SFSArray
- (id< ISFSObject >) getSFSObject: | (NSString *) | key |
Get the element for the provided key as an SFSObject
- (NSInteger) getShort: | (NSString *) | key |
Get the element for the provided key as a short int (16 bit) (int in AS3)
- (NSArray *) getShortArray: | (NSString *) | key |
Get the element for the provided key as an array of short int
- (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
- (NSInteger) getUnsignedByte: | (NSString *) | key |
Get the element for the provided key as a unsigned byte (8 bit) (int in AS3)
- (NSArray *) getUnsignedByteArray: | (NSString *) | key |
Get the element for the provided key as a an array of integers representing each byte as unsigned values
- (NSString *) getUtfString: | (NSString *) | key |
Get the element for the provided key as a UTF-8 String (use with strings <= 32KB)
- (NSArray *) getUtfStringArray: | (NSString *) | key |
Get the element for the provided key as an array of UTF-8 Strings (use with strings <= 32KBytes)
- (BOOL) isNull: | (NSString *) | key |
Checks if a specific element in the SFSObject is null
+ (id) newFromBinaryData: | (NSData *) | packet |
+ (id) newInstance |
Alternative static constructor
- (void) putBool: | (NSString *) | key | |
value: | (BOOL) | value | |
Put a Boolean value with the provided key
- (void) putBoolArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of Booleans with the provided key
- (void) putByte: | (NSString *) | key | |
value: | (NSInteger) | value | |
Put a byte value (8 bit) with the provided key
- (void) putByteArray: | (NSString *) | key | |
value: | (NSData *) | value | |
Put an array of bytes with the provided key
- (void) putDouble: | (NSString *) | key | |
value: | (NSNumber *) | value | |
Put a double (64 bit) with the provided key
- (void) putDoubleArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of doubles with the provided key
- (void) putFloat: | (NSString *) | key | |
value: | (NSNumber *) | value | |
Put a float (32 bit) with the provided key
- (void) putFloatArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of floats with the provided key
- (void) putInt: | (NSString *) | key | |
value: | (NSInteger) | value | |
Put an int (32 bit) with the provided key
- (void) putIntArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of ints with the provided key
- (void) putLong: | (NSString *) | key | |
value: | (NSNumber *) | value | |
Put a long int (64 bit) with the provided key
- (void) putLongArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of long ints with the provided key
- (void) putSFSArray: | (NSString *) | key | |
value: | (id<ISFSArray>) | value | |
- (void) putSFSObject: | (NSString *) | key | |
value: | (id<ISFSObject>) | value | |
Put an SFSObject with the provided key
- (void) putShort: | (NSString *) | key | |
value: | (NSInteger) | value | |
Put a short int (16 bit) with the provided key
- (void) putShortArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of short ints with the provided key
- (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
- (void) putUtfString: | (NSString *) | key | |
value: | (NSString *) | value | |
Put a UTF-8 String with the provided key
- (void) putUtfStringArray: | (NSString *) | key | |
value: | (NSArray *) | value | |
Put an array of Strings with the provided key (use with strings <= 32KB)
- (void) removeElement: | (NSString *) | key |
Removes an element
- (NSInteger) size |
Return the number of elements in the SFSObject
- (NSData *) toBinary |
Return the binary form of the object