Inherits from YYHRequest : NSObject
Declared in YYHJSONRequest.h
YYHJSONRequest.m

Overview

Simple and lightweight class for loading asynchronous HTTP requests w/ JSON. Built on NSURLConnection and NSOperationQueue. Uses NSJSONSerialization for reading and writing JSON.

Usage

 [YYHJSONRequest loadJSONWithURL:[NSURL URLWithString:@"http://foo.bar/json"] success:^(id json) {
    // json response
} failure:^(NSError *error) {
    // failure
}];

Properties

readingOptions

Options for reading the JSON data and creating the Foundation objects.

@property (nonatomic, assign) NSJSONReadingOptions readingOptions

Discussion

Options for reading the JSON data and creating the Foundation objects.

Declared In

YYHJSONRequest.h

writingOptions

Options for writing JSON data.

@property (nonatomic, assign) NSJSONWritingOptions writingOptions

Discussion

Options for writing JSON data.

Declared In

YYHJSONRequest.h

Class Methods

loadJSONWithURL:success:failure:

Create and load a JSON request.

+ (instancetype)loadJSONWithURL:(NSURL *)url success:(void ( ^ ) ( id json ))success failure:(void ( ^ ) ( NSError *error ))failure

Parameters

url

NSURL used to load the request.

success

Called when request has loaded successfully.

failure

Called when request fails to load.

Discussion

Create and load a JSON request.

Declared In

YYHJSONRequest.h

Instance Methods

initWithURL:

Initialize request.

- (instancetype)initWithURL:(NSURL *)url

Parameters

url

NSURL used to load the request.

success

Called when request has loaded successfully.

failure

Called when request fails to load.

Discussion

Initialize request.

Declared In

YYHRequest.h

loadJSONWithSuccess:failure:

Load a JSON request.

- (void)loadJSONWithSuccess:(void ( ^ ) ( id json ))success failure:(void ( ^ ) ( NSError *error ))failure

Parameters

success

Called when request has loaded successfully.

failure

Called when request fails to load.

url

NSURL used to load the request.

Discussion

Load a JSON request.

Declared In

YYHJSONRequest.h

onFailure:

Set callback block to be invoked when the request fails.

- (void)onFailure:(void ( ^ ) ( NSError *error ))failure

Discussion

Set callback block to be invoked when the request fails.

Declared In

YYHRequest.h

onJSONSuccess:

Set callback block to be invoked when the JSON request has loaded successfully.

- (void)onJSONSuccess:(void ( ^ ) ( id json ))success

Discussion

Set callback block to be invoked when the JSON request has loaded successfully.

Declared In

YYHJSONRequest.h