1. 첫 번째 학습 내용: Given, When, Then
- The given part describes the state of the world before you begin the behavior you're specifying in this scenario. You can think of it as the pre-conditions to the test.
- The when section is that behavior that you're specifying.
- Finally the then section describes the changes you expect due to the specified behavior.
자료 출처
GivenWhenThen provided by 올라프
2. 두 번째 학습 내용: URLSession
To help you with the many requirements for network requests, Apple provides URLSession, a complete networking API for uploading and downloading content.
URLSession is both a class and a suite of classes for handling HTTP- and HTTPS-based requests:
URLSession
is the key object responsible for sending and receiving requests. You create it via URLSessionConfiguration
, which comes in three flavors:
- default: Creates a default configuration object that uses the disk-persisted global cache, credential and cookie storage objects.
- ephemeral: Similar to the default configuration, except that you store all of the session-related data in memory. Think of this as a “private” session.
- background: Lets the session perform upload or download tasks in the background. Transfers continue even when the app itself is suspended or terminated by the system.
URLSessionConfiguration
also lets you configure session properties such as timeout values, caching policies and HTTP headers. Refer to Apple’s documentation for a full list of configuration options.
URLSessionTask
is an abstract class that denotes a task object. A session creates one or more tasks to do the actual work of fetching data and downloading or uploading files.
Understanding Session Task Types
There are three types of concrete session tasks:
- URLSessionDataTask: Use this task for GET requests to retrieve data from servers to memory.
- URLSessionUploadTask: Use this task to upload a file from disk to a web service via a POST or PUT method.
- URLSessionDownloadTask: Use this task to download a file from a remote service to a temporary file location.
You can also suspend, resume and cancel tasks. URLSessionDownloadTask
has the extra ability to pause for future resumption.
Generally, URLSession
returns data in two ways:
- Via a completion handler when a task finishes, either successfully or with an error; or,
- By calling methods on a delegate that you set when you create the session.
URLSession Tutorial: Getting Started by raywenderlich.com