networking in ios nsurlsession & nsstream

7
NSURLSESSION & NSSTREAM Manjula Jonnalagadda

Upload: manjula-jonnalagadda

Post on 11-Feb-2017

635 views

Category:

Mobile


1 download

TRANSCRIPT

Page 1: Networking in iOS NSURLSession & NSStream

NSURLSESSION & NSSTREAMManjula Jonnalagadda

Page 2: Networking in iOS NSURLSession & NSStream

NSURLSESSION

• Introduced in iOS 7

• Meant for downloading & Upload HTTP content

• Highly asynchronous

• Highly configurable

• Use completion handler or delegate

Page 3: Networking in iOS NSURLSession & NSStream

TYPES OF SESSIONS

• Default sessions - Uses disk cache and store credentials

• Ephemeral session - Uses no cache and doesn't store credentials

• Background session - Similar to default but uses separate process

Page 4: Networking in iOS NSURLSession & NSStream

CONFIGURATION

• Private support for caches, support, cookies for single session

• Control cookie policies

• Control HTTPPipelining behavior

• Per-resource timeouts

• Minimum and maximum version of TLS support

Page 5: Networking in iOS NSURLSession & NSStream

KINDS OF TASKS

• Data tasks - downloads data, does not save into file

• Download task - downloads and saves file into a file

• Upload task - send data probably a file

• Stream task - TCP data

Page 6: Networking in iOS NSURLSession & NSStream

COCOA CLASSES FOR STREAMS

• NSStream

• NSInputStream

• Stream to read the data from

• NSOutputStream

• Stream to write data to

Page 7: Networking in iOS NSURLSession & NSStream

USING STREAMS

• Create Streams from Socket

• Open

• Implement a delegate to listen to the events