RKObjectLoader Class Reference
Inherits from | RKRequest : NSObject |
Declared in | RKObjectLoader.h RKObjectLoader.m |
Overview
Wraps a request/response cycle and loads a remote object representation into local domain objects
NOTE: When Core Data is linked into the application, the object manager will return instances of RKManagedObjectLoader instead of RKObjectLoader. RKManagedObjectLoader is a descendent class that includes Core Data specific mapping logic.
Tasks
Other Methods
-
delegate
The object that acts as the delegate of the receiving object loader.
property -
onDidFailWithError
The block to invoke when the object loader fails due to an error.
property -
onDidLoadObject
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve a single object from the mapping result.
property -
onDidLoadObjects
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve an collections of objects from the mapping result.
property -
onDidLoadObjectsDictionary
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve the entire mapping result as a dictionary. Each key within the dictionary will correspond to a mapped keyPath within the source JSON/XML and the value will be the object mapped result.
property -
objectMapping
The object mapping to use when processing the response. If this is nil, then RestKit will search the parsed response body for mappable keyPaths and perform mapping on all available content. For instances where your target JSON is not returned under a uniquely identifiable keyPath, you must specify the object mapping directly for RestKit to know how to map it.
property -
mappingProvider
A mapping provider containing object mapping configurations for mapping remote object representations into local domain objects.
property -
response
The underlying response object for this loader
property -
result
The mapping result that was produced after the request finished loading and object mapping has completed. Provides access to the final products of the object mapper in a variety of formats.
property -
serializationMapping
The object mapping to use when serializing a target object for transport to the remote server.
property -
serializationMIMEType
The MIME Type to serialize the targetObject into according to the mapping rules in the serializationMapping. Typical MIME Types for serialization are JSON (RKMIMETypeJSON) and URL Form Encoded (RKMIMETypeFormURLEncoded).
property -
sourceObject
The object being serialized for transport. This object will be transformed into a serialization in the serializationMIMEType using the serializationMapping.
property -
targetObject
The target object to map results back onto. If nil, a new object instance for the appropriate mapping will be created. If not nil, the results will be used to update the targetObject’s attributes and relationships.
property -
mappingQueue
The Grand Central Dispatch queue to perform our parsing and object mapping within. By default, object loaders will use the mappingQueue from the RKObjectManager that created the loader. You can override this on a per-loader basis as necessary.
property -
+ loaderWithURL:mappingProvider:
Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider
-
– initWithURL:mappingProvider:
Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider
-
– handleResponseError
Handle an error in the response preventing it from being mapped, called from isResponseMappable
Other Methods
-
– reset
Resets the state of an RKRequest so that it can be re-sent.
-
– processMappingResult:
Overloaded by RKManagedObjectLoader to serialize/deserialize managed objects at thread boundaries. @protected
-
– prepareURLRequest
Setup the NSURLRequest.
-
– didFailLoadWithError:
Callback performed to notify the request that the underlying NSURLConnection has failed with an error.
-
– didFinishLoad:
Callback performed to notify the request that the underlying NSURLConnection has completed with a response.
Properties
delegate
The object that acts as the delegate of the receiving object loader.
@property (nonatomic, assign) id<> delegate
See Also
Declared In
RKObjectLoader.h
mappingProvider
A mapping provider containing object mapping configurations for mapping remote object representations into local domain objects.
@property (nonatomic, retain) RKObjectMappingProvider *mappingProvider
See Also
Declared In
RKObjectLoader.h
mappingQueue
The Grand Central Dispatch queue to perform our parsing and object mapping within. By default, object loaders will use the mappingQueue from the RKObjectManager that created the loader. You can override this on a per-loader basis as necessary.
@property (nonatomic, assign) dispatch_queue_t mappingQueue
Declared In
RKObjectLoader.h
objectMapping
The object mapping to use when processing the response. If this is nil, then RestKit will search the parsed response body for mappable keyPaths and perform mapping on all available content. For instances where your target JSON is not returned under a uniquely identifiable keyPath, you must specify the object mapping directly for RestKit to know how to map it.
@property (nonatomic, retain) RKObjectMapping *objectMapping
Discussion
@default nil
See Also
Declared In
RKObjectLoader.h
onDidFailWithError
The block to invoke when the object loader fails due to an error.
@property (nonatomic, copy) RKObjectLoaderDidFailWithErrorBlock onDidFailWithError
Declared In
RKObjectLoader.h
onDidLoadObject
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve a single object from the mapping result.
@property (nonatomic, copy) RKObjectLoaderDidLoadObjectBlock onDidLoadObject
Declared In
RKObjectLoader.h
onDidLoadObjects
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve an collections of objects from the mapping result.
@property (nonatomic, copy) RKObjectLoaderDidLoadObjectsBlock onDidLoadObjects
Declared In
RKObjectLoader.h
onDidLoadObjectsDictionary
The block to invoke when the object loader has completed object mapping and the consumer wishes to retrieve the entire mapping result as a dictionary. Each key within the dictionary will correspond to a mapped keyPath within the source JSON/XML and the value will be the object mapped result.
@property (nonatomic, copy) RKObjectLoaderDidLoadObjectsDictionaryBlock onDidLoadObjectsDictionary
Declared In
RKObjectLoader.h
response
The underlying response object for this loader
@property (nonatomic, readonly) RKResponse *response
Declared In
RKObjectLoader.h
result
The mapping result that was produced after the request finished loading and object mapping has completed. Provides access to the final products of the object mapper in a variety of formats.
@property (nonatomic, readonly) RKObjectMappingResult *result
Declared In
RKObjectLoader.h
serializationMIMEType
The MIME Type to serialize the targetObject into according to the mapping rules in the serializationMapping. Typical MIME Types for serialization are JSON (RKMIMETypeJSON) and URL Form Encoded (RKMIMETypeFormURLEncoded).
@property (nonatomic, retain) NSString *serializationMIMEType
Declared In
RKObjectLoader.h
serializationMapping
The object mapping to use when serializing a target object for transport to the remote server.
@property (nonatomic, retain) RKObjectMapping *serializationMapping
See Also
Declared In
RKObjectLoader.h
sourceObject
The object being serialized for transport. This object will be transformed into a serialization in the serializationMIMEType using the serializationMapping.
@property (nonatomic, retain) NSObject *sourceObject
See Also
Declared In
RKObjectLoader.h
targetObject
The target object to map results back onto. If nil, a new object instance for the appropriate mapping will be created. If not nil, the results will be used to update the targetObject’s attributes and relationships.
@property (nonatomic, retain) NSObject *targetObject
Declared In
RKObjectLoader.h
Class Methods
loaderWithURL:mappingProvider:
Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider
+ (id)loaderWithURL:(RKURL *)URL mappingProvider:(RKObjectMappingProvider *)mappingProvider
Parameters
- URL
A RestKit RKURL targetting a particular baseURL and resourcePath
- mappingProvider
A mapping provider containing object mapping configurations for processing loaded payloads
Declared In
RKObjectLoader.h
Instance Methods
didFailLoadWithError:
Callback performed to notify the request that the underlying NSURLConnection has failed with an error.
- (void)didFailLoadWithError:(NSError *)error
Parameters
- error
An NSError object containing the RKRestKitError that triggered the callback.
Declared In
RKRequest.h
didFinishLoad:
Callback performed to notify the request that the underlying NSURLConnection has completed with a response.
- (void)didFinishLoad:(RKResponse *)response
Parameters
- response
An RKResponse object with the result of the request.
Declared In
RKRequest.h
handleResponseError
Handle an error in the response preventing it from being mapped, called from isResponseMappable
- (void)handleResponseError
Declared In
RKObjectLoader.h
initWithURL:mappingProvider:
Initialize and return an autoreleased object loader targeting a remote URL using a mapping provider
- (id)initWithURL:(RKURL *)URL mappingProvider:(RKObjectMappingProvider *)mappingProvider
Parameters
- URL
A RestKit RKURL targetting a particular baseURL and resourcePath
- mappingProvider
A mapping provider containing object mapping configurations for processing loaded payloads
Declared In
RKObjectLoader.h
prepareURLRequest
Setup the NSURLRequest.
- (BOOL)prepareURLRequest
Return Value
A boolean for the success of the URL preparation.
Discussion
The request must be prepared right before dispatching.
Declared In
RKRequest.h
processMappingResult:
Overloaded by RKManagedObjectLoader to serialize/deserialize managed objects at thread boundaries. @protected
- (void)processMappingResult:(RKObjectMappingResult *)result
Declared In
RKObjectLoader.m