SBBObjectManager Class Reference

Inherits from NSObject
Conforms to SBBComponent
SBBObjectManagerProtocol
Declared in SBBObjectManager.h
SBBObjectManager.m

Overview

This class handles converting between Bridge API JSON objects and corresponding client objects. It is used internally by the various API managers for that purpose.

Other Methods

+ objectManager

Use this method to create an independent object manager instance for testing.

+ (instancetype)objectManager

Return Value

A fresh SBBObjectManager instance.

Declared In

SBBObjectManager.h

Other Methods

– objectFromBridgeJSON:

Create a client object from JSON obtained via the Bridge API.

- (id)objectFromBridgeJSON:(id)json

Parameters

json

A JSON object from the Bridge API.

Return Value

A client object (built-in or custom) representing that Bridge API object.

Discussion

By default, the object will be an instance (or array) of class SBB, where is the Bridge API object type as indicated in its “type” field, and SBB is an SBBBridgeObject subclass with properties matching the fields defined for in the API documentation.

You can override this by setting up a mapping between and a custom class via the setupMappingForType:toClass:fieldToPropertyMappings: method. In that case API manager methods in this SDK will use the classes defined in these mappings to pass data back and forth between your app and the Bridge API in place of the built-in SBB classes.

Declared In

SBBObjectManager.h

– bridgeJSONFromObject:

Create a Bridge JSON object (or array) from a client object.

- (id)bridgeJSONFromObject:(id)object

Parameters

object

The client object to convert to JSON for the Bridge API.

Return Value

JSON representing that client object.

Discussion

If object is an instance of a built-in SBB class, it will be converted into a JSON Bridge object of .

If object is an instance of a class mapped from a type via setupMappingForType:toClass:fieldToPropertyMappings:, it will be reverse-converted according to the defined mapping to a JSON Bridge object of the mapped-from type.

If the object is an NSDate object, it will be converted to an ISO 8601 date string.

If the object is a standard JSON object (NSArray, NSDictionary, NSString, NSNumber), it will just be returned as-is.

Any other kind of object will be ignored and this method will return nil.

Declared In

SBBObjectManager.h

– setupMappingForType:toClass:fieldToPropertyMappings:

Set up an SDK-wide mapping between Bridge API objects of a specified type and a particular client class, with Bridge object field names mapped to class properties according to a given dictionary.

- (void)setupMappingForType:(NSString *)type toClass:(Class)mapToClass fieldToPropertyMappings:(NSDictionary *)mappings

Parameters

type

The Bridge API type being mapped.

mapToClass

The client class to which it is to be mapped.

mappings

Keys are Bridge API field names; values are the corresponding class property names. A nil value for this parameter will cause the SDK to use the Bridge API field names as the corresponding class property names.

Discussion

By default, unless an explicit mapping has been set up for a given Bridge API object type, the mapping will be done to an internal class named SBB with property names matching the field names defined for the Bridge API object type.

Declared In

SBBObjectManager.h

– clearMappingForType:

Clear any previously set up SDK-wide mapping of Bridge API objects of the specified type.

- (void)clearMappingForType:(NSString *)type

Parameters

type

The Bridge API type being un-mapped.

Discussion

The implicit mapping will revert to an internal class named SBB with property names matching the field names defined for the Bridge API object type.

Declared In

SBBObjectManager.h