Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 2.21 KB

README.md

File metadata and controls

38 lines (27 loc) · 2.21 KB

Maris

The glue between AFNetworking and Mantle


[![Build Status](https://travis-ci.org/ScottPetit/Maris.png?branch=master)](https://travis-ci.org/ScottPetit/Maris)

Maris is the glue between AFNetworking and Mantle. With Maris you never have to write another AFNetworking Response Serializer again. Just tell Maris what MTLModel subclass to use and get your fully formed objects back.

Maris was inspired by me trying to use Overcoat on a project but wanting to use the NSURLSession side of AFNetworking. Therefore Maris supports NSURLSession and AFNetworking out of the box.

Maris is named after Roger Maris, a former American baseball player who is most known for hitting (at the time) a Major League record 61 home runs during the 1961 season for the New York Yankees, breaking Babe Ruth's single-season record of 60 home runs in 1927.

Usage

Maris provides two subclasses of AFNetworking classes. REMHTTPSessionManager and REMHTTPRequestOperationManager. These provide the interface by which you can unify AFNetworking and Mantle. Instead of using the AFHTTPSessionManager method of

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

Maris provides a method like this

REMHTTPSessionManager *manager = [REMHTTPSessionManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil modelClass:[MYObject class] keyPath:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Model object(s): %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

By providing the modelClass and the key path for your objects (can be nil), Maris is able to handle deserializing JSON into your model objects. It’s that easy.