#import <Z5URLSessionController.h>
|
NSURLSession * | session [implementation] |
|
NSURLSessionDataTask * | finderTask [implementation] |
|
Definition at line 11 of file Z5URLSessionController.h.
◆ createSession()
- (NSURLSession *) createSession |
|
|
|
|
implementation |
Definition at line 20 of file Z5URLSessionController.m.
22 static NSURLSession *
session = nil;
23 session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
25 delegateQueue:[NSOperationQueue mainQueue]];
◆ fetchUSDAdata:withCompletionBlock:()
- (void) fetchUSDAdata: |
|
(NSURLRequest *) |
request |
withCompletionBlock: |
|
(void(^)(NSDictionary *informationDictionary, NSError *error)) |
incomingDictionary |
|
|
| |
Definition at line 109 of file Z5URLSessionController.m.
109 :(NSURLRequest *)request withCompletionBlock:(
void(^)(NSDictionary *informationDictionary, NSError *error)) completionBlock
111 NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
113 NSString *cachePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"/nsurlsessiondemo.cache"];
115 NSURLCache *myCache = [[NSURLCache alloc] initWithMemoryCapacity: 16384
116 diskCapacity: 268435456
117 diskPath: cachePath];
118 defaultConfigObject.URLCache = myCache;
120 defaultConfigObject.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
122 NSURLSession *delegateFreeSession = [NSURLSession sessionWithConfiguration: defaultConfigObject
124 delegateQueue: [NSOperationQueue mainQueue]];
129 [[delegateFreeSession dataTaskWithRequest:request
130 completionHandler:^(NSData *data, NSURLResponse *response,
133 NSLog(@"Z5URLSessionControl.fetchUSDAdata: Got response %@ with error %@.\n", response, error);
135 NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
136 completionBlock (dataDictionary, error);
138 NSLog(@"Z5URLSessionControl.fetchUSDAdata: ERROR: %@", error);
◆ findDataUsingDelegate()
- (void) findDataUsingDelegate |
|
|
|
Definition at line 30 of file Z5URLSessionController.m.
32 self.session = [
self createSession];
34 NSURL *dataURL = [NSURL URLWithString:@"http://google.com"];
35 NSURLRequest *request = [NSURLRequest requestWithURL:dataURL];
36 self.finderTask = [
self.session dataTaskWithRequest:request];
37 [
self.finderTask resume];
◆ URLSession:dataTask:didReceiveData:()
- (void) URLSession: |
|
(NSURLSession *) |
session |
dataTask: |
|
(NSURLSessionDataTask *) |
dataTask |
didReceiveData: |
|
(NSData *) |
data |
|
|
| |
|
implementation |
Definition at line 41 of file Z5URLSessionController.m.
41 :(NSURLSession *)session
42 dataTask:(NSURLSessionDataTask *)dataTask
43 didReceiveData:(NSData *)data{
45 NSString* newStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
46 NSLog(
@"URLSessController.didReceiveData: raw: %@", newStr);
◆ URLSession:dataTask:willCacheResponse:completionHandler:()
- (void) URLSession: |
|
(NSURLSession *) |
session |
dataTask: |
|
(NSURLSessionDataTask *) |
dataTask |
willCacheResponse: |
|
(NSCachedURLResponse *) |
proposedResponse |
completionHandler: |
|
(void(^)(NSCachedURLResponse *cachedResponse)) |
completionHandler |
|
|
| |
|
implementation |
Definition at line 60 of file Z5URLSessionController.m.
60 :(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask
61 willCacheResponse:(NSCachedURLResponse *)proposedResponse
62 completionHandler:(
void (^)(NSCachedURLResponse *cachedResponse))completionHandler{
64 NSLog(
@"Here now: %s",__func__);
◆ URLSession:task:didCompleteWithError:()
- (void) URLSession: |
|
(NSURLSession *) |
session |
task: |
|
(NSURLSessionTask *) |
task |
didCompleteWithError: |
|
(NSError *) |
error |
|
|
| |
|
implementation |
Definition at line 67 of file Z5URLSessionController.m.
67 :(NSURLSession *)session
68 task:(NSURLSessionTask *)task
69 didCompleteWithError:(NSError *)error{
70 NSLog(
@"Here now: %s",__func__);
◆ finderTask
- (NSURLSessionDataTask*) finderTask |
|
readwritenonatomicstrongimplementation |
◆ session
- (NSURLSession*) session |
|
readwritenonatomicstrongimplementation |
The documentation for this class was generated from the following files: