YYHJSONRequest Class Reference
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
}];
Tasks
Configuring a Request
-
readingOptions
property -
writingOptions
property -
– onJSONSuccess:
Loading a JSON Request
Other Methods
Properties
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