#import <MPJSONModel.h>
A protocol describing an abstract MPJSONModel class MPJSONModel conforms to this protocol, so it can use itself abstractly
◆ initWithData:error:
- (instancetype) initWithData: |
|
(NSData *) |
data |
error: |
|
(NSError **) |
error |
|
|
| |
|
required |
All MPJSONModel classes should implement initWithData:error:
For most classes the default initWithData: inherited from MPJSONModel itself should suffice, but developers have the option to also overwrite it if needed.
- Parameters
-
data | representing a JSON response (usually fetched from web), to be imported in the model. |
error | an error or NULL |
◆ initWithDictionary:error:
- (instancetype) initWithDictionary: |
|
(NSDictionary *) |
dict |
error: |
|
(NSError **) |
err |
|
|
| |
|
required |
All MPJSONModel classes should implement initWithDictionary:
For most classes the default initWithDictionary: inherited from MPJSONModel itself should suffice, but developers have the option to also overwrite it if needed.
- Parameters
-
dict | a dictionary holding JSON objects, to be imported in the model. |
err | an error or NULL |
◆ toDictionary
- (NSDictionary *) toDictionary |
|
|
|
|
required |
All MPJSONModel classes should be able to export themselves as a dictionary of JSON compliant objects.
For most classes the inherited from MPJSONModel default toDictionary implementation should suffice.
- Returns
- NSDictionary dictionary of JSON compliant objects
- Exceptions
-
MPJSONModelTypeNotAllowedException | thrown when one of your model's custom class properties does not have matching transformer method in an MPJSONValueTransformer. |
◆ toDictionaryWithKeys:
- (NSDictionary *) toDictionaryWithKeys: |
|
(NSArray< NSString * > *) |
propertyNames |
|
|
required |
Export a model class to a dictionary, including only given properties
- Parameters
-
propertyNames | the properties to export; if nil, all properties exported |
- Returns
- NSDictionary dictionary of JSON compliant objects
- Exceptions
-
MPJSONModelTypeNotAllowedException | thrown when one of your model's custom class properties does not have matching transformer method in an MPJSONValueTransformer. |
The documentation for this protocol was generated from the following file: