Slide 1

Slide 1 text

2

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

@mattt @sco

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

State of the Library

Slide 11

Slide 11 text

• 8,800+ Stars • 2,200+ Forks • 1,500+ Commits • 1,300+ Closed Issues • 130 Contributors

Slide 12

Slide 12 text

Continuous Integration Automated Documentation

Slide 13

Slide 13 text

Official Extensions • OAuth 1.0a • OAuth 2.0 • Amazon S3 • JSON-RPC • Collection+JSON • Logger

Slide 14

Slide 14 text

Official Extensions

Slide 15

Slide 15 text

Official Extensions http://mneorr.github.io/Alcatraz/ Download Xcode Template with Alcatraz

Slide 16

Slide 16 text

Third-Party Extensions • XAuth • CSV • iCalendar • HAR (HTTP Archive) • RSS • Gravatar • WebDav

Slide 17

Slide 17 text

Built on AFNetworking RestKit NimbusKit OctoKit

Slide 18

Slide 18 text

10,000's Built on AFNetworking Apps Built Using AFNetworking

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 705 What’s New in Foundation Networking

Slide 22

Slide 22 text

NSURLSession

Slide 23

Slide 23 text

NSURLSession • Session Configuration • URL Cache • Protocols • Cookie Storage • Tasks • Backgroundable • Data, Upload, & Download

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

AFNetworking 2.0

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

AFNetworking 2.0 • iOS 6+ & Mac OS X 10.8+ • Xcode 5 • NSURLSession & NSURLConnection • Serialization Modules • UIKit Extensions • Real-time

Slide 28

Slide 28 text

Requirements

Slide 29

Slide 29 text

Serializers

Slide 30

Slide 30 text

AFURLConnectionOperation AFHTTPRequestOperation AFJSONRequestOperation

Slide 31

Slide 31 text

- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" #pragma clang diagnostic ignored "-Wgnu" self.completionBlock = ^ { if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ failure(self, self.error); }); } } else { dispatch_async(json_request_operation_processing_queue(), ^{ id JSON = self.responseJSON; if (self.error) { if (failure) { dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ failure(self, self.error); }); } } else { if (success) { dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ success(self, JSON); }); } } }); } }; #pragma clang diagnostic pop }

Slide 32

Slide 32 text

- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { __weak __typeof(self)weakSelf = self; [super setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { __strong __typeof(weakSelf)strongSelf = weakSelf; if (![responseObject isKindOfClass:[NSData class]]) { [strongSelf setResponseJSON:responseObject]; } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf setError:error]; }]; }

Slide 33

Slide 33 text

op.responseSerializer = [AFJSONSerializer serializer];

Slide 34

Slide 34 text

- requestBySerializingRequest: withParameters: error: - responseObjectForResponse: data: error:

Slide 35

Slide 35 text

• Shared Between Request Operations & Session Tasks • Significantly Reduced Boilerplate Code • Pluggable & Configurable • Protocol, Not Subclass Serializers

Slide 36

Slide 36 text

Built-in Serializers • HTTP • JSON • Property List • HTTP • JSON • XML Parser • XML Document (OSX) • Property List • Image Request Response

Slide 37

Slide 37 text

Serializer Extensions • MsgPack • CSV / TSV • vCard • vCal • WebP

Slide 38

Slide 38 text

Object Serialization • NSObject • NSManagedObject • RKManagedObject • MTLModel

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Changes to AFHTTPRequestOperation • You'll Actually Use it Directly! • @property responseSerializer • @property completionQueue • @property completionGroup

Slide 42

Slide 42 text

NSURL *URL = [NSURL URLWithString:@"http://example.com/foo.json"]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFJSONSerializer serializer]; [operation start];

Slide 43

Slide 43 text

AFURLConnectionOperation AFHTTPRequestOperation AFJSONRequestOperation

Slide 44

Slide 44 text

AFURLConnectionOperation AFHTTPRequestOperation

Slide 45

Slide 45 text

Content Operation Extension • AFJSONRequestOperation • AFXMLRequestOperation • AFPropertyListRequestOperation • AFImageRequestOperation

Slide 46

Slide 46 text

AFURLSessionManager

Slide 47

Slide 47 text

NSURLSession 2 Methods 5 Methods 4 Methods 3 Methods

Slide 48

Slide 48 text

NSURLSession 14 Delegate Methods

Slide 49

Slide 49 text

AFURLSessionManager • Provides Block-based Callbacks for Delegate Methods • Including Default Expected Implementation • Provides Per-Task Upload / Download Progress Callbacks • Convenience Methods for Session Management

Slide 50

Slide 50 text

AFHTTPClient the

Slide 51

Slide 51 text

AFHTTPClient • Create Requests • Parameter Query String Serialization • Multipart Form Stream Creation • Default Headers • Create and Manage Request Operations • Create Batched Operations • Monitor Network Reachability

Slide 52

Slide 52 text

New Architecture • • • AFSecurityPolicy • AFNetworkReachabilityManager

Slide 53

Slide 53 text

New Architecture NSURLConnection NSURLSession AFHTTPRequestOperation AFURLConnectionOperation Data Upload Download NSURLSessionTask NSURLSessionTask NSURLSessionTask AFHTTPClient AFHTTPSessionManager AFURLSessionManager

Slide 54

Slide 54 text

AFHTTPSessionManager • Expanded & Refactored HTTP Convenience Methods • Almost identical between Session & Request Operation Managers • Default to JSON Response Serializer • No Longer Requires baseURL

Slide 55

Slide 55 text

- (Object *)GET:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *, id))success failure:(void (^)(Object *, NSError *))failure; - (Object *)HEAD:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *))success failure:(void (^)(Object *, NSError *))failure;

Slide 56

Slide 56 text

- (Object *)POST:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *, id))success failure:(void (^)(Object *, NSError *))failure; - (Object *)POST:(NSString *)URLString parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id ))block success:(void (^)(Object *, id))success failure:(void (^)(Object *, NSError *))failure;

Slide 57

Slide 57 text

- (Object *)PUT:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *, id))success failure:(void (^)(Object *, NSError *))failure; - (Object *)PATCH:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *, id))success failure:(void (^)(Object *, NSError *))failure; - (Object *)DELETE:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(Object *))success failure:(void (^)(Object *, NSError *))failure;

Slide 58

Slide 58 text

- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request completionHandler:(void (^)( NSHTTPURLResponse *, id, NSError *error ))completionHandler;

Slide 59

Slide 59 text

- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL progress:(NSProgress **)progress completionHandler:(void (^)( NSHTTPURLResponse *, id, NSError *error ))completionHandler; - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData progress:(NSProgress **)progress completionHandler:(void (^)( NSHTTPURLResponse *, id, NSError *error ))completionHandler;

Slide 60

Slide 60 text

- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request progress:(NSProgress **)progress completionHandler:(void (^)( NSHTTPURLResponse *, NSURL *, NSError *error ))completionHandler; - (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData progress:(NSProgress **)progress completionHandler:(void (^)( NSHTTPURLResponse *, NSURL *, NSError *error ))completionHandler;

Slide 61

Slide 61 text

AFSecurityPolicy • Evaluate Server Trust • Pinned Certificates • Pinned Public Keys • Validate Server Certs

Slide 62

Slide 62 text

AFNetworkReachability Manager • Monitor Network Reachability • Domain • IP Address • Determine Type of Connection

Slide 63

Slide 63 text

UIKit Extensions

Slide 64

Slide 64 text

UIKit Extensions • Network Activity Indicator • UIImageView • UIButton • UIActivityIndicatorView • UIProgressView • UIWebView

Slide 65

Slide 65 text

Real-time

Slide 66

Slide 66 text

R O C K E T a hybrid approach to real-time cloud applications

Slide 67

Slide 67 text

Server-Sent Events W3C Event Source Draft Spec JSON Patch RFC 6902

Slide 68

Slide 68 text

Document Stream Request Response GET /resources Accept: application/json SUBSCRIBE /resources Accept: text/event-stream HTTP/1.1 200 OK Content-Type: application/json {"resources": [...]} HTTP/1.1 200 OK Content-Type: text/event-stream event: patch data: [{ "op": "add", "path": "/resources/123", "value": {...} }]

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; [manager SUBSCRIBE:@"http://example.com/resources" usingBlock:^(NSArray *operations, NSError *error) { for (AFJSONPatchOperation *operation in operations) { switch (operation.type) { case AFJSONAddOperationType: [self.resources addObject:operation.value]; break; case AFJSONRemoveOperationType: [self.resources removeObject:operation.value]; break; } } } error:nil]; [manager GET:@"http://example.com/resources" parameters:nil success:^(NSHTTPURLResponse *response, id responseObject) { self.resources = responseObject; } failure:nil];

Slide 71

Slide 71 text

rocket.github.io

Slide 72

Slide 72 text

helios an extensible open source mobile backend framework

Slide 73

Slide 73 text

Helios Services • Data Synchronization • Push Notification Registration • In-App Purchase • Passbook Webservice • Newsstand Syndication • Logging & Analytics

Slide 74

Slide 74 text

require 'bundler' Bundler.require app = Helios::Application.new { service :data, model: "Model.xcdatamodel" service :push_notification service :in_app_purchase service :passbook } run app

Slide 75

Slide 75 text

helios.io

Slide 76

Slide 76 text

AFNetworking 2.0 • iOS 6+ & Mac OS X 10.8+ • Xcode 5 • NSURLSession & NSURLConnection • Serialization Modules • UIKit Extensions • Real-time

Slide 77

Slide 77 text

AFNetworking 2.0 GA Soon!

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

@mattt

Slide 81

Slide 81 text

One more thing...

Slide 82

Slide 82 text

AFNetworking the definitive guide

Slide 83

Slide 83 text

AFNetworking the definitive guide Coming Fall 2013

Slide 84

Slide 84 text

Thank !