networking in ios nsurlsession & nsstream
TRANSCRIPT
NSURLSESSION & NSSTREAMManjula Jonnalagadda
NSURLSESSION
• Introduced in iOS 7
• Meant for downloading & Upload HTTP content
• Highly asynchronous
• Highly configurable
• Use completion handler or delegate
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
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
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
COCOA CLASSES FOR STREAMS
• NSStream
• NSInputStream
• Stream to read the data from
• NSOutputStream
• Stream to write data to
USING STREAMS
• Create Streams from Socket
• Open
• Implement a delegate to listen to the events