The object mapping engine of a RestKit is built on the KVC informal protocol, which is foundational to numerous Cocoa technologies, such as Key-Value observing, bindings, and Core Data. After the response body was parsed, RestKit relies on KVC to identify the content that can be mapped and dynamically updates the attributes and relationships of your local domain objects with the appropriate content. Before diving into the details of RestKit's object mapping system, be sure to get familiar with Apple's Key-Value Coding and go through its programming guide at the following link:
Using a highly dynamic Objective-C runtime, RestKit examines the type of source and destination properties of object and performs appropriate type transformations. For example, when a JSON is parsed and a source key path created_at
(with a string content) is configured to be mapped to a destination key path, creationDate
(this is an NSDate
property on a target object), RestKit will transform the date from a string into an NSDate
property using an
NSDateFormatter
. The other transformations can be string to number and vice versa, or a developer can build his own transformation strategy, if needed.
The mapper also fully supports relationship mappings, where nested to-one or to-many child objects are mapped recursively.