25.12.2013 Views

URL Loading System Programming Guide - Apple Developer

URL Loading System Programming Guide - Apple Developer

URL Loading System Programming Guide - Apple Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using NS<strong>URL</strong>Session<br />

Sample Delegate Class Interface<br />

NSCopying Behavior<br />

Session and task objects conform to the NSCopying protocol as follows:<br />

●<br />

●<br />

When your app copies a session or task object, you get the same object back.<br />

When your app copies a configuration object, you get a new copy that you can independently modify.<br />

Sample Delegate Class Interface<br />

The code snippets in the following task sections are based on the class interface shown in Listing 1-1.<br />

Listing 1-1<br />

Sample delegate class interface<br />

#import <br />

typedef void (^CompletionHandlerType)();<br />

@interface MySessionDelegate : NSObject <br />

@property NS<strong>URL</strong>Session *backgroundSession;<br />

@property NS<strong>URL</strong>Session *defaultSession;<br />

@property NS<strong>URL</strong>Session *ephemeralSession;<br />

#if TARGET_OS_IPHONE<br />

@property NSMutableDictionary *completionHandlerDictionary;<br />

#endif<br />

- (void) addCompletionHandler: (CompletionHandlerType) handler forSession: (NSString<br />

*)identifier;<br />

- (void) callCompletionHandlerForSession: (NSString *)identifier;<br />

@end<br />

2013-10-22 | Copyright © 2003, 2013 <strong>Apple</strong> Inc. All Rights Reserved.<br />

18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!