|
37 | 37 |
|
38 | 38 | ## Mappings Dictionary
|
39 | 39 |
|
40 |
| - The mappings dictionary describes how to object map the source object. The keys of the dictionary are key paths into the `sourceObject` and the values are `RKMapping` objects describing how to map the representations at the corresponding key path. This dictionary based approach enables a single document to contain an arbitrary number of object representations that can be mapped independently. Consider the following example JSON structure: |
| 40 | + The mappings dictionary describes how to object map the source object. The keys of the dictionary are key paths into the `representation` and the values are `RKMapping` objects describing how to map the representations at the corresponding key path. This dictionary based approach enables a single document to contain an arbitrary number of object representations that can be mapped independently. Consider the following example JSON structure: |
41 | 41 |
|
42 | 42 | { "tags": [ "hacking", "phreaking" ], "authors": [ "Captain Crunch", "Emmanuel Goldstein" ], "magazine": { "title": "2600 The Hacker Quarterly" } }
|
43 | 43 |
|
|
52 | 52 |
|
53 | 53 | ### The NSNull Key
|
54 | 54 |
|
55 |
| - A mapping set for the key `[NSNull null]` value has special significance to the mapper operation. When a mapping is encountered with the a null key, the entire `sourceObject` is processed using the given mapping. This provides support for mapping content that does not have an outer nesting attribute. |
| 55 | + A mapping set for the key `[NSNull null]` value has special significance to the mapper operation. When a mapping is encountered with the a null key, the entire `representation` is processed using the given mapping. This provides support for mapping content that does not have an outer nesting attribute. |
56 | 56 |
|
57 | 57 | ## Data Source
|
58 | 58 |
|
59 | 59 | The data source is used to instantiate new objects or find existing objects to be updated during the mapping process. The object set as the `mappingOperationDataSource` will be set as the `dataSource` for the `RKMappingOperation` objects created by the mapper.
|
60 | 60 |
|
61 | 61 | ## Target Object
|
62 | 62 |
|
63 |
| - If a `targetObject` is configured on the mapper operation, all mapping work on the `sourceObject` will target the specified object. For transient `NSObject` mappings, this ensures that the properties of an existing object are updated rather than an new object being created for the mapped representation. If an array of representations is being processed and a `targetObject` is provided, it must be a mutable collection object else an exception will be raised. |
| 63 | + If a `targetObject` is configured on the mapper operation, all mapping work on the `representation` will target the specified object. For transient `NSObject` mappings, this ensures that the properties of an existing object are updated rather than an new object being created for the mapped representation. If an array of representations is being processed and a `targetObject` is provided, it must be a mutable collection object else an exception will be raised. |
64 | 64 |
|
65 | 65 | ## Core Data
|
66 | 66 |
|
|
75 | 75 | /**
|
76 | 76 | Initializes the operation with a source object and a mappings dictionary.
|
77 | 77 |
|
78 |
| - @param object An `NSDictionary` or `NSArray` of `NSDictionary` object representations to be mapped into local domain objects. |
| 78 | + @param representation An `NSDictionary` or `NSArray` of `NSDictionary` object representations to be mapped into local domain objects. |
79 | 79 | @param mappingsDictionary An `NSDictionary` wherein the keys are mappable key paths in `object` and the values are `RKMapping` objects specifying how the representations at its key path are to be mapped.
|
80 | 80 | @return The receiver, initialized with the given object and and dictionary of key paths to mappings.
|
81 | 81 | */
|
82 |
| -- (id)initWithObject:(id)object mappingsDictionary:(NSDictionary *)mappingsDictionary; |
| 82 | +- (id)initWithRepresentation:(id)representation mappingsDictionary:(NSDictionary *)mappingsDictionary; |
83 | 83 |
|
84 | 84 | ///------------------------------------------
|
85 | 85 | /// @name Accessing Mapping Result and Errors
|
|
100 | 100 | ///-------------------------------------
|
101 | 101 |
|
102 | 102 | /**
|
103 |
| - The source object representation against which the mapping is performed. |
| 103 | + The representation of one or more objects against which the mapping is performed. |
104 | 104 |
|
105 | 105 | Either an `NSDictionary` or an `NSArray` of `NSDictionary` objects.
|
106 | 106 | */
|
107 |
| -@property (nonatomic, strong, readonly) id sourceObject; |
| 107 | +@property (nonatomic, strong, readonly) id representation; |
108 | 108 |
|
109 | 109 | /**
|
110 |
| - A dictionary of key paths to `RKMapping` objects specifying how object representations in the `sourceObject` are to be mapped. |
| 110 | + A dictionary of key paths to `RKMapping` objects specifying how object representations in the `representation` are to be mapped. |
111 | 111 |
|
112 | 112 | Please see the above discussion for in-depth details about the mappings dictionary.
|
113 | 113 | */
|
|
130 | 130 | */
|
131 | 131 | @property (nonatomic, weak) id<RKMapperOperationDelegate> delegate;
|
132 | 132 |
|
| 133 | +- (BOOL)execute:(NSError **)error; |
| 134 | + |
133 | 135 | @end
|
134 | 136 |
|
135 | 137 | ///--------------------------------------
|
|
177 | 179 |
|
178 | 180 | @param mapper The mapper operation performing the mapping.
|
179 | 181 | @param dictionaryOrArrayOfDictionaries The `NSDictictionary` or `NSArray` of `NSDictionary` object representations that was found at the `keyPath`.
|
180 |
| - @param keyPath The key path that the representation was read from in the `sourceObject`. If the `keyPath` was `[NSNull null]` in the `mappingsDictionary`, it will be given as `nil` to the delegate. |
| 182 | + @param keyPath The key path that the representation was read from in the `representation`. If the `keyPath` was `[NSNull null]` in the `mappingsDictionary`, it will be given as `nil` to the delegate. |
181 | 183 | */
|
182 | 184 | - (void)mapper:(RKMapperOperation *)mapper didFindRepresentationOrArrayOfRepresentations:(id)dictionaryOrArrayOfDictionaries atKeyPath:(NSString *)keyPath;
|
183 | 185 |
|
|
194 | 196 | ///----------------------------------------------
|
195 | 197 |
|
196 | 198 | /**
|
197 |
| - Tells the delegate that the mapper is about to start a mapping operation to map a representation found in the `sourceObject`. |
| 199 | + Tells the delegate that the mapper is about to start a mapping operation to map a representation found in the `representation`. |
198 | 200 |
|
199 | 201 | @param mapper The mapper operation performing the mapping.
|
200 | 202 | @param mappingOperation The mapping operation that is about to be started.
|
201 |
| - @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `sourceObject`. |
| 203 | + @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `representation`. |
202 | 204 | */
|
203 | 205 | - (void)mapper:(RKMapperOperation *)mapper willStartMappingOperation:(RKMappingOperation *)mappingOperation forKeyPath:(NSString *)keyPath;
|
204 | 206 |
|
|
207 | 209 |
|
208 | 210 | @param mapper The mapper operation performing the mapping.
|
209 | 211 | @param mappingOperation The mapping operation that has finished.
|
210 |
| - @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `sourceObject`. |
| 212 | + @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `representation`. |
211 | 213 | */
|
212 | 214 | - (void)mapper:(RKMapperOperation *)mapper didFinishMappingOperation:(RKMappingOperation *)mappingOperation forKeyPath:(NSString *)keyPath;
|
213 | 215 |
|
|
216 | 218 |
|
217 | 219 | @param mapper The mapper operation performing the mapping.
|
218 | 220 | @param mappingOperation The mapping operation that has failed.
|
219 |
| - @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `sourceObject`. |
| 221 | + @param keyPath The key path that was mapped. A `nil` key path indicates that the mapping matched the entire `representation`. |
220 | 222 | @param error The error that occurred during the execution of the mapping operation.
|
221 | 223 | */
|
222 | 224 | - (void)mapper:(RKMapperOperation *)mapper didFailMappingOperation:(RKMappingOperation *)mappingOperation forKeyPath:(NSString *)keyPath withError:(NSError *)error;
|
|
0 commit comments