O'Reilly logo

RestKit for iOS by Taras Kalapun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Error mapping

If the server is capable of returning proper error messages in response, we will be able to map them and output directly to the user. So, if the server is capable of returning error message in the JSON response as follows:

{
  "error": "No matching database associated with this account",
  "code": 1005
}

Then, we can use it to show to the user. To do so, create an error mapping for the RKErrorMessage class as follows:

// You can map errors to any class // RKErrorMessage is included within RestKit RKObjectMapping *errorMapping = [RKObjectMapping mappingForClass:[RKErrorMessage class]]; // Map error information to the errorMessage property in our class [errorMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:nil toKeyPath:@"errorMessage"]]; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required