Udacity Networking in iOS and Swift Flashcards

1
Q

What is a singleton?

A

A singleton is an special kind of object that can only be instantiated once. So if you use the shared URLSession in this file, and then in a another file you use the shared URL session, you’re actually still referring to the same object in both files, becuase it’s a singleton there can only be one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a completion handler?

A

A completion handler is a block of code that is executed after something completes like a network task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is ATS?

A

App Transport Security - ATS

Apple’s set of security standards for ensuring our apps keep users’ data safe.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is URL in Swift?

A

URL represents a URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is URLSession ?

A

URLSession manages network requests for our app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is URLSessionConfiguration ?

A

URLSessionConfiguration specifies settings (eg timeout interval) for a NSURLSession (or URLSession?)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is URLSessionTask ?

A

URLSessionTask is a network task that can be executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is URLSessionDataTask ?

A

URLSessionDataTask is a subclass of NSURLSessionTask; it downloads data directly into memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is URLSessionDownloadTask ?

A

URLSessionDownloadTask is a subclass of NSURLSessionTask; it downloads data temporary file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is URLSessionUploadTask ?

A

URLSessionUploadTask is a subclass of NSURLSessionTask; it is specialsed for uploading data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is URLResponse ?

A

URLResponse is a container for information about the response to a network request such its status code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Error ?

A

Error is a container for information about an error condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the steps for getting JSON data and parsing it?

A
  1. Get the raw JSON data.
  2. Parse the JSON data into a foundation object, like an NS dictionary, or an NSArray.
  3. Grab the data from the Foundation object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe deserialising JSON?

A
  • get photos dictionary at the “photos” key
  • in the photos dictionary, get the array of the photo dictionaries at the “photo” key
  • print the first photo dictionary
if let photosDictionary = parsedResult[Constants.FlickrResponseKeys.Photos] as? [String:AnyObject], let photoArray = photosDictionary[Constants.FlickrResponseKeys.Photo] as? [[String:AnyObject]] {
                        print(photoArray[0])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In terms of URLComponents, break down the structure of a web address and building it

A

Note we do this because the URLComponents class ensure that all characters are escaped and URL contains only safe ascii characters

The URL:
https://api.flickr.com/services/rest?
method=flickr.photos.search&
api_key=980958230459843086554&
text=purple

First line: :// / (to ?)

everything after the ? is the query

They consist of name: value pairs that a server uses to determine its response -
eg
text=purple
method=method=flickr.photos.search&amp
These are name=value. Each pair is separated by an &

To add the query line (eg after the ? to the end), we need to add a URLQueryItem (see below), add the key : value pairs, and then append them to the component var (aka the URL)

var components = URLComponents()

components. scheme = “https”
components. host = “api.flickr.com”
components. path = “/services/rest”
components. queryItems = URLQueryItem

let queryItem1 = URLQueryItem(name: "method", value: "flickr.photos.search")
let queryItem2 = URLQueryItem(name: "api_key", value: "1234")
let queryItem3 = URLQueryItem(name: "text", value: "purple")

components. queryItems!.append(queryItem1)
components. queryItems!.append(queryItem2)
components. queryItems!.append(queryItem3)

print(components.url!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Network

A

Network — the system of interconnected computer networks from which we can access data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Data

A

Data — images, text, video, or any media that can be used by our apps.

18
Q

Protocol

A

Protocol — a way of communicating; standard operating procedure; the rules for communication

19
Q

HTTP

A

HTTP (Hypertext Transfer Protocol) — a protocol or “handshake” that defines how messages (and data) are sent and received by computers; the underlying protocol for the World Wide We

20
Q

Client

A

Client — a computer that requests data (or services) from a server

21
Q

Server

A

Server — a computer that provides data (or services) to a client upon request

22
Q

HTTP request

A

HTTP request — a request for data (or a resource) that a client makes to a server; there are various types of HTTP requests called “HTTP methods”

23
Q

URL

A

URL (Uniform Resource Locator) — specifies the location for retrieving data over the web; can be thought of as the name of a file on the World Wide Web, because it usually refers to a file on some machine on the network

24
Q

HTTP method

A

HTTP method — specifies the type of HTTP request that is being made; in this course, we will also called these (HTTP) request types

25
Q

HTTP status code

A

HTTP status code — a number returned in response to an HTTP request which indicates the result of the request; you may also hear these referred to as “response codes” or “status messages”; here is a nice listing of different HTTP status codes

26
Q

HTTP GET request

A

HTTP GET request — a type of HTTP request where a client requests a specified resource from a server

27
Q

Completion handler

A

Completion handler — a block of code that is executed after something completes like a network task

28
Q

HTTPS

A

HTTPS — a protocol built on top of HTTP that ensures data sent over the network is encrypted, or concealed, from unauthorized access

29
Q

ATS

A

ATS (App Transport Security) — Apple’s set of security standards for ensuring our apps keep users’ data safe

30
Q

Singleton

A

Singleton — a special kind of object that can only be instantiated once

31
Q

URL

A

URL — represents a URL

32
Q

URLSession — manages network requests for our app

A

URLSession — manages network requests for our app

33
Q

URLSessionConfiguration

A

URLSessionConfiguration — specify settings (ex. timeout interval) for a NSURLSession

34
Q

URLSessionTask

A

URLSessionTask — a network task that can be executed

35
Q

URLSessionDataTask

A

URLSessionDataTask — subclass of NSURLSessionTask; downloads data directly into memory

36
Q

URLSessionDownloadTask

A

URLSessionDownloadTask — subclass of NSURLSessionTask; downloads data to a temporary file

37
Q

URLSessionUploadTask

A

URLSessionUploadTask — subclass of NSURLSessionTask; specialized for uploading data

38
Q

Data

A

Data — represents data as raw bytes

39
Q

URLResponse

A

URLResponse — a container for information about the response to a network request such its status code

40
Q

Error

A

Error — a container for information about an error condition