Your SlideShare is downloading. ×
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Everybody Loves AFNetworking ... and So Can you!
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Everybody Loves AFNetworking ... and So Can you!

7,265

Published on

Brooklyn iOS Developer Meetup …

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/

0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,265
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
60
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Everybody Loves AFNetworking ...and So Can You!Mattt ThompsonHeroku
  • 2. @mattt
  • 3. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  • 4. AFURLConnectionOperation
  • 5. NSURLConnection + NSOperation
  • 6. NSURLConnection• High-Level Networking API• Delegate-based Callbacks
  • 7. URL Loading System• URL Loading • Authentication & Credentials • NSURLConnection • NSURLRequest • NSURLCredential • NSURLResponse • NSURLAuthenticationChallenge• Caching • Cookies • NSURLCache • NSHTTPCookie • NSURLCacheResponse • Protocols • NSProtocol
  • 8. NSURLConnection Delegate Methods - connection:didReceiveResponse: - connection:didReceiveData: - connectionDidFinishLoading: - connection:didFailWithError: - connection:willCacheResponse:
  • 9. NSOperation• Atomic Unit of Computation • Concurrently executed in NSOperationQueue• Encapsulates State • started, executing, finished• Cancelable• Completion Blocks
  • 10. AFURLConnectionOperation• NSOperation Subclass• Implements NSURLConnection Delegate Methods• Supports Streaming Uploads / Downloads• Stores Request, Response, Data
  • 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. AFURLConnectionOperation
  • 13. AFHTTPRequestOperationAFURLConnectionOperation
  • 14. AFHTTPRequestOperation • AFURLConnectionOperation Subclass • Adds Knowledge Specific to HTTP • Status Codes • MIME Types • Adds Success / Failure Distinction
  • 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. AFHTTPRequestOperationAFURLConnectionOperation
  • 17. JSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  • 18. Operations should encapsulate everything ittakes to get what you want
  • 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. 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. NSURL *URL = [NSURL URLWithString:@"http://example.com/avatar.jpg"];[cell.imageView setImageWithURL:URL placeholderImage:[UIImage imageNamed:@"placeholder"]];
  • 22. JSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  • 23. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  • 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. • Create NSURLRequest• Create AFHTTPRequestOperation• Enqueue Operations
  • 26. AFHTTPClientJSON XML plist Image AFHTTPRequestOperation AFURLConnectionOperation
  • 27. Collection UIKit +JSON Extensions OAuth AFHTTPClient JSON XML plist Image S3 AFHTTPRequestOperation AFURLConnectionOperation
  • 28. AFNetworking Ecosystem• AFOAuth1Client & AFOAuth2Client• AFAmazonS3Client• AFDownloadRequestOperation• AFIncrementalStore• AFKissXMLRequestOperation• AFCollectionJSONRequestOperation• AFHTTPRequestOperationLogger
  • 29. AFFuture• Working Towards 1.0• AFIncrementalStore• More Examples & Documentation• Modular CocoaPods Specification
  • 30. How You Can Help• Documentation & Guides • Especially non-English• Pitch In on Stack Overflow• Issues• Pull Requests
  • 31. Thanks!

×