Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Everybody Loves    AFNetworking ...and So Can You!Mattt ThompsonHeroku
@mattt
AFHTTPClientJSON    XML     plist   Image   AFHTTPRequestOperation  AFURLConnectionOperation
AFURLConnectionOperation
NSURLConnection      +  NSOperation
NSURLConnection• High-Level Networking API• Delegate-based Callbacks
URL Loading System• URL Loading                • Authentication &                               Credentials    •   NSURLCo...
NSURLConnection Delegate Methods - connection:didReceiveResponse: - connection:didReceiveData: - connectionDidFinishLoadin...
NSOperation• Atomic Unit of Computation  • Concurrently executed in NSOperationQueue• Encapsulates State  • started, execu...
AFURLConnectionOperation• NSOperation Subclass• Implements NSURLConnection Delegate Methods• Supports Streaming Uploads / ...
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/ip"];NSURLRequest *request = [NSURLRequest requestWithURL:URL];AFUR...
AFURLConnectionOperation
AFHTTPRequestOperationAFURLConnectionOperation
AFHTTPRequestOperation • AFURLConnectionOperation Subclass • Adds Knowledge Specific to HTTP   • Status Codes   • MIME Typ...
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/robots.txt"];NSURLRequest *request = [NSURLRequest requestWithURL:U...
AFHTTPRequestOperationAFURLConnectionOperation
JSON    XML     plist   Image   AFHTTPRequestOperation  AFURLConnectionOperation
Operations should encapsulate everything ittakes to get what you want
Success / Failure              JSON               XML           ImageStatus          2XX               2XX             2XX...
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];NSURLRequest *request = [NSURLRequest requestWithURL:URL];AFJ...
NSURL *URL = [NSURL URLWithString:@"http://example.com/avatar.jpg"];[cell.imageView setImageWithURL:URL               plac...
JSON    XML     plist   Image   AFHTTPRequestOperation  AFURLConnectionOperation
AFHTTPClientJSON    XML     plist   Image   AFHTTPRequestOperation  AFURLConnectionOperation
AFHTTPClient• Designed to Work for Single Endpoint• Set Default Headers  • Authorization, Accept, Accept-Language, etc.• E...
• Create NSURLRequest• Create AFHTTPRequestOperation• Enqueue Operations
AFHTTPClientJSON    XML     plist   Image   AFHTTPRequestOperation  AFURLConnectionOperation
Collection                    UIKit +JSON                     Extensions                                                  ...
AFNetworking Ecosystem• AFOAuth1Client & AFOAuth2Client• AFAmazonS3Client• AFDownloadRequestOperation• AFIncrementalStore•...
AFFuture• Working Towards 1.0• AFIncrementalStore• More Examples & Documentation• Modular CocoaPods Specification
How You Can Help• Documentation & Guides • Especially non-English• Pitch In on Stack Overflow• Issues• Pull Requests
Thanks!
Everybody Loves AFNetworking ... and So Can you!
Upcoming SlideShare
Loading in …5
×

Everybody Loves AFNetworking ... and So Can you!

8,532 views

Published on

Brooklyn iOS Developer Meetup
Presenter: Mattt Thompson
Topic: Everybody loves AFNetworking
Location: NYU Poly Incubator DUMBO Brooklyn, NY

http://www.meetup.com/The-Brooklyn-iPhone-and-iPad-Developer-Meetup/

  • Be the first to comment

Everybody Loves AFNetworking ... and So Can you!

  1. 1. Everybody Loves AFNetworking ...and So Can You!Mattt ThompsonHeroku
  2. 2. @mattt
  3. 3. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  4. 4. AFURLConnectionOperation
  5. 5. NSURLConnection + NSOperation
  6. 6. NSURLConnection• High-Level Networking API• Delegate-based Callbacks
  7. 7. URL Loading System• URL Loading • Authentication & Credentials • NSURLConnection • NSURLRequest • NSURLCredential • NSURLResponse • NSURLAuthenticationChallenge• Caching • Cookies • NSURLCache • NSHTTPCookie • NSURLCacheResponse • Protocols • NSProtocol
  8. 8. NSURLConnection Delegate Methods - connection:didReceiveResponse: - connection:didReceiveData: - connectionDidFinishLoading: - connection:didFailWithError: - connection:willCacheResponse:
  9. 9. NSOperation• Atomic Unit of Computation • Concurrently executed in NSOperationQueue• Encapsulates State • started, executing, finished• Cancelable• Completion Blocks
  10. 10. AFURLConnectionOperation• NSOperation Subclass• Implements NSURLConnection Delegate Methods• Supports Streaming Uploads / Downloads• Stores Request, Response, Data
  11. 11. NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/ip"];NSURLRequest *request = [NSURLRequest requestWithURL:URL];AFURLConnectionOperation *operation = [[AFURLConnectionOperation alloc] initWithRequest:request];operation.completionBlock = ^ { NSLog(@"Complete: %@", operation.responseString);};[operation start];
  12. 12. AFURLConnectionOperation
  13. 13. AFHTTPRequestOperationAFURLConnectionOperation
  14. 14. AFHTTPRequestOperation • AFURLConnectionOperation Subclass • Adds Knowledge Specific to HTTP • Status Codes • MIME Types • Adds Success / Failure Distinction
  15. 15. NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/robots.txt"];NSURLRequest *request = [NSURLRequest requestWithURL:URL];AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];[operation setCompletionBlockWithSuccess: ^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Success: %@", operation.responseString);} failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Failure: %@", error);}];[operation start];
  16. 16. AFHTTPRequestOperationAFURLConnectionOperation
  17. 17. JSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  18. 18. Operations should encapsulate everything ittakes to get what you want
  19. 19. Success / Failure JSON XML ImageStatus 2XX 2XX 2XXCode image/tiffContent application/json text/json application/xml image/jpeg Type text/javascript text/xml image/gif image/png
  20. 20. NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];NSURLRequest *request = [NSURLRequest requestWithURL:URL];AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, idJSON) { NSLog(@"Success :%@", JSON); } failure:^(NSURLRequest *request, NSHTTPURLResponse *response,NSError *error, id JSON) { NSLog(@"Failure: %@", error); }];[operation start];
  21. 21. NSURL *URL = [NSURL URLWithString:@"http://example.com/avatar.jpg"];[cell.imageView setImageWithURL:URL placeholderImage:[UIImage imageNamed:@"placeholder"]];
  22. 22. JSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  23. 23. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  24. 24. AFHTTPClient• Designed to Work for Single Endpoint• Set Default Headers • Authorization, Accept, Accept-Language, etc.• Encode Parameters to Query String or Message Body• Handle Multipart Form Request Body Construction• Manage Request Operations
  25. 25. • Create NSURLRequest• Create AFHTTPRequestOperation• Enqueue Operations
  26. 26. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  27. 27. Collection UIKit +JSON Extensions OAuth AFHTTPClient JSON XML plist Image S3 AFHTTPRequestOperation AFURLConnectionOperation
  28. 28. AFNetworking Ecosystem• AFOAuth1Client & AFOAuth2Client• AFAmazonS3Client• AFDownloadRequestOperation• AFIncrementalStore• AFKissXMLRequestOperation• AFCollectionJSONRequestOperation• AFHTTPRequestOperationLogger
  29. 29. AFFuture• Working Towards 1.0• AFIncrementalStore• More Examples & Documentation• Modular CocoaPods Specification
  30. 30. How You Can Help• Documentation & Guides • Especially non-English• Pitch In on Stack Overflow• Issues• Pull Requests
  31. 31. Thanks!

×