NSScreencast Episode #91 AFNetworking 2.0
AFNetworking 2.0 - NSScreencast
AFNetworking 2.0使って画像を表示とか
- Podfile
- platform :ios, '7.0'
- pod 'AFNetworking', '~> 2.0.1'
- view controller
- #import "AFNetworking.h"
- AFHTTPSessionManager
- [self GET:@"/search"
- parameters
- country
- term
- dispatch_async(dispatch_get_main_queue()
- sharedClient
- [NSURLSessionConfiguration defaultSessionConfiguration];
- _sharedClient.responseSerializer = [AFJSONResponseSerializer serializer];
- NSURLCache
- initWithMemoryCapacity:10 * 1024 * 1024
- diskCapacity:50 * 1024 * 1024
- diskPath:nil
- [config setURLCache:cache];
- #import "UIImageView+AFNetworking.h"
- cell.artworkImageView
- cancelImageRequestOperation
- setImageWithURL:imageURL
- cell.artworkImageView
- #import "UIActivityIndicatorView+AFNetworking.h"
- UIActivityIndicatorView
- initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray
- searchForTerm
- setNetworkActivityIndicatorVisible:YES];
- [self.indicator setAnimatingWithStateOfTask:task];
- UIActivityIndicatorView
- new class itunes client, subclass
- ITunesClient : AFHTTPSessionManager
- sharedClient
- static ITunesClient *_sharedClient = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedClient
- ITunesClient : AFHTTPSessionManager