Conforms to RKRequestDelegate
Declared in RKObjectLoader.h

Overview

The delegate of an RKObjectLoader object must adopt the RKObjectLoaderDelegate protocol. Optional methods of the protocol allow the delegate to handle asynchronous object mapping operations performed by the object loader. Also note that the RKObjectLoaderDelegate protocol incorporates the RKRequestDelegate protocol and the delegate may provide implementations of methods from RKRequestDelegate as well.

Tasks

  • – objectLoader:didFailWithError:

    Sent when an object loaded failed to load the collection due to an error

    required method
  • – objectLoader:didLoadObjects:

    When implemented, sent to the delegate when the object laoder has completed successfully and loaded a collection of objects. All objects mapped from the remote payload will be returned as a single array.

  • – objectLoader:didLoadObject:

    When implemented, sent to the delegate when the object loader has completed succesfully. If the load resulted in a collection of objects being mapped, only the first object in the collection will be sent with this delegate method. This method simplifies things when you know you are working with a single object reference.

  • – objectLoader:didLoadObjectDictionary:

    When implemented, sent to the delegate when an object loader has completed successfully. The dictionary will be expressed as pairs of keyPaths and objects mapped from the payload. This method is useful when you have multiple root objects and want to differentiate them by keyPath.

  • – objectLoaderDidFinishLoading:

    Invoked when the object loader has finished loading

  • – objectLoader:didSerializeSourceObject:toSerialization:

    Informs the delegate that the object loader has serialized the source object into a serializable representation for sending to the remote system. The serialization can be modified to allow customization of the request payload independent of mapping.

  • – objectLoaderDidLoadUnexpectedResponse:

    Sent when an object loader encounters a response status code or MIME Type that RestKit does not know how to handle.

  • – objectLoader:willMapData:

    Invoked just after parsing has completed, but before object mapping begins. This can be helpful to extract data from the parsed payload that is not object mapped, but is interesting for one reason or another. The mappableData will be made mutable via mutableCopy before the delegate method is invoked.

Instance Methods

objectLoader:didFailWithError:

Sent when an object loaded failed to load the collection due to an error

- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error

Declared In

RKObjectLoader.h

objectLoader:didLoadObject:

When implemented, sent to the delegate when the object loader has completed succesfully. If the load resulted in a collection of objects being mapped, only the first object in the collection will be sent with this delegate method. This method simplifies things when you know you are working with a single object reference.

- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObject:(id)object

Declared In

RKObjectLoader.h

objectLoader:didLoadObjectDictionary:

When implemented, sent to the delegate when an object loader has completed successfully. The dictionary will be expressed as pairs of keyPaths and objects mapped from the payload. This method is useful when you have multiple root objects and want to differentiate them by keyPath.

- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjectDictionary:(NSDictionary *)dictionary

Declared In

RKObjectLoader.h

objectLoader:didLoadObjects:

When implemented, sent to the delegate when the object laoder has completed successfully and loaded a collection of objects. All objects mapped from the remote payload will be returned as a single array.

- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)objects

Declared In

RKObjectLoader.h

objectLoader:didSerializeSourceObject:toSerialization:

Informs the delegate that the object loader has serialized the source object into a serializable representation for sending to the remote system. The serialization can be modified to allow customization of the request payload independent of mapping.

- (void)objectLoader:(RKObjectLoader *)objectLoader didSerializeSourceObject:(id)sourceObject toSerialization:(inout id<RKRequestSerializable> *)serialization

Parameters

objectLoader

The object loader performing the serialization.

sourceObject

The object that was serialized.

serialization

The serialization of sourceObject to be sent to the remote backend for processing.

Declared In

RKObjectLoader.h

objectLoader:willMapData:

Invoked just after parsing has completed, but before object mapping begins. This can be helpful to extract data from the parsed payload that is not object mapped, but is interesting for one reason or another. The mappableData will be made mutable via mutableCopy before the delegate method is invoked.

- (void)objectLoader:(RKObjectLoader *)loader willMapData:(inout id *)mappableData

Discussion

Note that the mappable data is a pointer to a pointer to allow you to replace the mappable data with a new object to be mapped. You must dereference it to access the value.

Declared In

RKObjectLoader.h

objectLoaderDidFinishLoading:

Invoked when the object loader has finished loading

- (void)objectLoaderDidFinishLoading:(RKObjectLoader *)objectLoader

Declared In

RKObjectLoader.h

objectLoaderDidLoadUnexpectedResponse:

Sent when an object loader encounters a response status code or MIME Type that RestKit does not know how to handle.

- (void)objectLoaderDidLoadUnexpectedResponse:(RKObjectLoader *)objectLoader

Discussion

Response codes in the 2xx, 4xx, and 5xx range are all handled as you would expect. 2xx (successful) response codes are considered a successful content load and object mapping will be attempted. 4xx and 5xx are interpretted as errors and RestKit will attempt to object map an error out of the payload (provided the MIME Type is mappable) and will invoke objectLoader:didFailWithError: after constructing an NSError. Any other status code is considered unexpected and will cause objectLoaderDidLoadUnexpectedResponse: to be invoked provided that you have provided an implementation in your delegate class.

RestKit will also invoke objectLoaderDidLoadUnexpectedResponse: in the event that content is loaded, but there is not a parser registered to handle the MIME Type of the payload. This often happens when the remote backend system RestKit is talking to generates an HTML error page on failure. If your remote system returns content in a MIME Type other than application/json or application/xml, you must register the MIME Type and an appropriate parser with the [RKParserRegistry sharedParser] instance.

Also note that in the event RestKit encounters an unexpected status code or MIME Type response an error will be constructed and sent to the delegate via objectLoader:didFailsWithError: unless your delegate provides an implementation of objectLoaderDidLoadUnexpectedResponse:. It is recommended that you provide an implementation and attempt to handle common unexpected MIME types (particularly text/html and text/plain).

@optional

Declared In

RKObjectLoader.h