TRCValueTransformer
aimed to convert simple (atomic) typed objects, received as response, into objects to use inside app, and vise versa.
More...
Instance Methods | |
(id) | - objectFromResponseValue:error: |
Converts received value into custom object. More... | |
(id) | - requestValueFromObject:error: |
Converts object into value which can be used in request. More... | |
(TRCValueTransformerType) | - externalTypes |
BitMask of value types (TRCValueTransformerType ), used in request and response. More... | |
TRCValueTransformer
aimed to convert simple (atomic) typed objects, received as response, into objects to use inside app, and vise versa.
Examples:
- (id TRCValueTransformer) objectFromResponseValue: | (id) | responseValue | |
error: | (NSError **) | error | |
Converts received value into custom object.
responseValue | input value to process, has external type (type which can be used in your serialization format) |
error | pointer to write back |
- (id TRCValueTransformer) requestValueFromObject: | (id) | object | |
error: | (NSError **) | error | |
Converts object into value which can be used in request.
object | object specified in request |
error | error to write back |
|
optional |
BitMask of value types (TRCValueTransformerType
), used in request and response.
Used for validation purpose. If not implemented, TRCValueTransformerTypeString is assumed
external means that these types used outside the app, so we have to convert them into app's types. For example JSON has only number and string value - they are external types. Inside app we have NSData and we want to send it to the server we can't send our NSDate using JSON directly, but we can convert NSDate into NSNumber or NSString. This method declares acceptable types, that sounds like 'this value transformer accepts NSNumber for response value and at same time, it converts NSDate into NSNumber'.
See TRCValueTransformerType
for more details about available values
Validation examples:
TRCValueTransformerTypeString
but received response value is not string, that will cause validation error.TRCValueTransformerTypeString
but request value after transforming is not string, that also will cause a validation error.