RKMappingResult Class Reference
| Inherits from | NSObject |
| Declared in | RKMappingResult.h |
Overview
The RKMappingResult class represents the aggregate object mapping results returned by an RKMapperOperation object. The mapping result provides a thin interface on top of an NSDictionary and provides convenient interfaces for accessing the mapping results in various representations.
Tasks
Creating a Mapping Result
-
– initWithDictionary:Initializes the receiver with a dictionary of mapped key paths and object values.
Retrieving Result Representations
-
– dictionaryReturns a representation of the mapping result as a dictionary.
-
– firstObjectReturns a representation of the mapping result as a single object by returning the first mapped value from the aggregate array of mapped objects.
-
– arrayReturns a representation of the mapping result as an array of objects.
-
– setReturns a representation of the mapping result as a set of objects.
Counting Entries
-
– countReturns a count of the number of objects contained in the mapping result. This is an aggregate count of all objects across all mapped key paths in the result.
Instance Methods
array
Returns a representation of the mapping result as an array of objects.
- (NSArray *)arrayReturn Value
An array containing the objects contained in the mapping result.
Discussion
The array returned is a flattened collection of all mapped object values contained in the underlying dictionary result representation. No guarantee is made as to the ordering of objects within the returned collection when more than one key path was mapped, as NSDictionary objects are unordered,
Declared In
RKMappingResult.hcount
Returns a count of the number of objects contained in the mapping result. This is an aggregate count of all objects across all mapped key paths in the result.
- (NSUInteger)countReturn Value
A count of the number of mapped objects in the mapping result.
Declared In
RKMappingResult.hdictionary
Returns a representation of the mapping result as a dictionary.
- (NSDictionary *)dictionaryReturn Value
A dictionary containing the mapping results.
Discussion
The keys of the returned dictionary will correspond to the mapped key paths in the source object representation and the values will be the mapped objects. The returned value is a copy of the dictionary that was used to initialize the mapping result.
Declared In
RKMappingResult.hfirstObject
Returns a representation of the mapping result as a single object by returning the first mapped value from the aggregate array of mapped objects.
- (id)firstObjectReturn Value
The first object contained in the mapping result.
Discussion
The mapping result is coerced into a single object by retrieving all mapped objects and returning the first object. If the mapping result is empty, nil is returned.
Declared In
RKMappingResult.hinitWithDictionary:
Initializes the receiver with a dictionary of mapped key paths and object values.
- (id)initWithDictionary:(NSDictionary *)dictionaryParameters
- dictionary
A dictionary wherein the keys represent mapped key paths and the values represent the objects mapped at those key paths. Cannot be nil.
Return Value
The receiver, initialized with the given dictionary.
Declared In
RKMappingResult.hset
Returns a representation of the mapping result as a set of objects.
- (NSSet *)setReturn Value
A set containing the objects contained in the mapping result.
Discussion
The set returned is a flattened collection of all mapped object values contained in the underlying dictionary result representation.
Declared In
RKMappingResult.h