General Flashcards

1
Q

How to get .p12?

A

tylko osoba która go tworzy ma klucz prywatny i to ona musi Ci go dać z własnego keychaina

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

Coordinator key points

A

The coordinator pattern organizes flow logic between view controllers. It involves a coordinator protocol, concrete coordinator, router protocol, concrete router and view controllers.
The coordinator defines methods and properties all concrete coordinators must implement.
The concrete coordinators know how to create concrete view controllers and their
order.
The router defines methods all concrete routers must implement.
The concrete routers know how to present view controllers.
The concrete view controllers are typical view controllers, but they don’t know about other view controllers.
This pattern can be adopted for only part of an app or used across an entire application.

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

Avoid making real networking calls in your unit tests by mocking

A

URLSession and URLSessionDataTask.

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

Do TDD for GET requests easily by breaking them into several smaller tasks:

A

calling the right URL, handling HTTP status errors, handling valid and invalid responses.

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

How to test Networking Client?

A

Create URLSession and URLSessionDataTask mocks
Inject them to your Client
Test how Client behave under your cases and situations

Test for:
calling the right URL
handling error responses
test for deserialising models
test for Dispatching to a response queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Save completion vs call completion after another request

A

Call completion you use when you are also waiting for some completion

save completion to pass data later in your test

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

There are two ways you can create a mock network client in Swift:

A
  1. You can create a mock by subclassing DogPatchClient and overriding each of its methods. This works, but you may accidentally make real network calls if you forget to override a method. You may also cause side effects, such as caching fake network responses.
    You can create a network client protocol and depend on this instead of DogPatchClient directly.
  2. You can create a mock object by implementing it. In turn, you eliminate the possibility of making real network calls or causing side effects. Nice! The main downside of this approach is that you must create an extra type for the protocol. However, this is usually very quick and easy to do.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

you should create a mock network client using a

A

protocol instead of subclassing-and-overriding.

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

What you should add to your network client protocol?

A

You shouldn’t add implementation details.

A consumer doesn’t need to know how you constructed its dependency; they only need to know the behavior the dependency provides. This, in turn, defines which methods and properties go into the protocol.

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

Testing flow

A

Create mocks for dependencies your SUT
Create a test for initialization
Start testing from easer to more complex tasks
After each test see what I can refactor

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

There are two different types of cryptography

A

symmetric cryptography, and asymmetric cryptography.

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

“use Keychain Access to export your identity, and you wanted to format it in a .cer (certificate) format,

A

you’d only be exporting the public key.

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

to properly export the full identity from keychain

A

you must use the PKCS12 format (.p12) to properly export the full identity, private key and all

But be careful: whoever has the private key can assume the full identity for that company, at least from Apple’s perspective

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

What are Entitlements

A

Embedded in (almost) every compiled application is a set of entitlements: again, this is an XML string embedded in the application saying what an app can and can’t do. Other programs will check for permissions (or lack thereof) in the entitlements and grant or deny a request accordingly. Think of the capabilities section found in Xcode.

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

Attach debugger entitlement

A

get-task-allow entitlement

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

What provisioning profiles include?

A

public x509 certificate, the list of approved devices as well as the entitlements all embedded into one file

TeamIdentifier
Entitlements
IsXcodeManaged
Name
ProvisionedDevices
DeveloperCertificates
AppIDName
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Certificate it’s like

A

public key in security

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

Public key cryptography is based on the premise that there are two keys

A

: one key for encrypting, and one key for decrypting.

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

Public key

A

public key is something that you can share freely.

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

Private key

A

You can think of the private key like an actual key that you have to protect and keep safe

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

Dynamic frameworks vs static frameworks

A

A dynamic framework is a bundle of code loaded into an executable at runtime, instead of at compile time

Examples in iOS include UIKit and the Foundation frameworks. Frameworks such as these contain a dynamic library and optionally assets, such as images.

There are numerous advantages to electing to use dynamic frameworks instead of static frameworks. The most obvious advantage is you can make updates to the framework without having to recompile the executable that depends on the framework.

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

An initializer must assign a value to every single stored property that

A

does not have a default value, or else you’ll get a compiler error. Remember that optional variables automatically have a default value of nil.

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

Throw failure vs optional nil

A

By using throwing initializers you can not only indicate failure, but also indicate a reason by throwing specific errors.

Nil has no reason

Failable initializers are much simpler though, since you don’t need to define an error type and you can avoid all those extra try? keywords.

24
Q

designated initializer is just a fancy term for

A

a non-delegating initializer.

25
Q

designated initializers] are responsible for

A

providing initial values to all non-optional stored properties declared without a default value

26
Q

Override all of a superclass’s set of designated initializers in order to

A

re-inherit the superclass’s set of convenience initializers.

27
Q

When overriding a superclass designated initializer, you can either make it

A

a designated initializer or a convenience initializer

28
Q

Conditionally Conforming to a Protocol

A

where

29
Q

Providing Default Implementations for protocols

A

Protocol requirements with default implementations provided by extensions are distinct from optional protocol requirements. Although conforming types don’t have to provide their own implementation of either, requirements with default implementations can be called without optional chaining.

30
Q

Give instances what they

A

only needed

Restrict to only read functionality

31
Q

Recursive Enumerations

A

A recursive enumeration is an enumeration that has another instance of the enumeration as the associated value for one or more of the enumeration cases. You indicate that an enumeration case is recursive by writing indirect before it, which tells the compiler to insert the necessary layer of indirection.

32
Q

you should think of memory management from the perspective

A

of object ownership and object graphs.

33
Q

Choosing Between Structures and Classes

A

Use structures by default.

Use classes when you need Objective-C interoperability.

Use classes when you need to control the identity of the data you’re modeling.

Use structures along with protocols to adopt behavior by sharing implementations.

Use Structures When You Don’t Control Identity

34
Q

Choose Structures by Default

A

Use structures to represent common kinds of data. Structures in Swift include many features that are limited to classes in other languages: They can include stored properties, computed properties, and methods. Moreover, Swift structures can adopt protocols to gain behavior through default implementations. The Swift standard library and Foundation use structures for types you use frequently, such as numbers, strings, arrays, and dictionaries.

Using structures makes it easier to reason about a portion of your code without needing to consider the whole state of your app. Because structures are value types—unlike classes—local changes to a structure aren’t visible to the rest of your app unless you intentionally communicate those changes as part of the flow of your app. As a result, you can look at a section of code and be more confident that changes to instances in that section will be made explicitly, rather than being made invisibly from a tangentially related function call.

35
Q

stack

A

More efficient when allocating and deallocating data.
Stacks store value types, such as structs and enums.

Data stored in the stack is only there temporarily until the function exits and causes all memory on the stack to be automatically deallocated.

Makes memory lookup and access very fast from how well it is organized.
The most frequently reserved block is the first to be freed.

36
Q

Concurrency vs Parallelism

A

Parallelism is about doing work at the same time.

Concurrency is about the option to do work at the same time.

37
Q

The great advantage of Dispatch Queues is, that it changes your mental model of concurrent programming. how?

A

Instead of thinking in threads, you consider it as blocks of work pushed onto different queues, which is a lot easier.

38
Q

You should never try to call the methods of an RunLoop object

A

running in a different thread, as doing so might cause unexpected results.

39
Q

Synchronisation in swift @synchronized

A
let serialQueue = DispatchQueue(label: "com.test.mySerialQueue") 
serialQueue.sync { // code }
40
Q

What avoid to store in Controllers?

A

we should try as hard as possible to avoid storing state in Controllers

41
Q

Controller is like a

A

Controller is Mediator

42
Q

or when you notice a lot of business logic settling down in Controllers, consider

A

wrapping those Model objects in a Facade which will hide the complexity and implementation details.

43
Q

People often neglect the logic part and make their Models data-only objects which are then manipulated

A

by Controllers keeping all the logic, with the consequence that Models become thin and Controllers become fat.

44
Q

Don’t try to use MVC as one single structural design pattern but rather

A

as a guideline for good application architecture, or a set of design patterns which can solve some of our problems.

45
Q

Background modes cases

A

Play audio: The app can continue playing and/or recording audio in the background. - Ask for permission

Receive location updates: The app can continue to get callbacks as the device’s location changes. - Ask for permission

Perform finite-length tasks: The generic “whatever” case, where the app can run arbitrary code for a limited amount of time. -

registerBackgroundTask() tells iOS that you need more time to complete whatever it is that you’re doing in case the app moves to the background

Background Fetch: Get updates to the latest content scheduled by iOS.

46
Q

Perform finite-length tasks: The generic “whatever” case, where the app can run arbitrary code for a limited amount of time. how to Configure?

A

◦ registerBackgroundTask() tells iOS that you need more time to complete whatever it is that you’re doing in case the app moves to the background

47
Q

Background Fetch: Get updates to the latest content scheduled by iOS. how to configure?

A

AppDelegate.swift and add the following to application(_:didFinishLaunchingWithOptions:):

you must implement application(_:performFetchWithCompletionHandler:). Add that now to AppDelegate:

48
Q

Explain SOLID

A
Single Responsibility Principle
Open/closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
49
Q

Single Responsibility Principle

A

One class should only have one responsibility

50
Q

What is ETC principle

A

Think what is Easier To Change when write code

51
Q

Open/closed Principle

A
Open for extension: You should be able to extend or change the behaviors of a class without efforts.
Closed for modification: You must extend a class without changing the implementation.
52
Q

Liskov Substitution Principle

A

objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

53
Q

Interface Segregation Principle

A

many client-specific interfaces are better than one general-purpose interface

54
Q

Dependency inversion principle

A

one should “depend upon abstractions, [not] concretions.

55
Q

DI vs IoC

A

IoC is a generic term meaning rather than having the application call the methods in a framework, the framework calls implementations provided by the application.

DI is a form of IoC, where implementations are passed into an object through constructors/setters/service lookups, which the object will ‘depend’ on in order to behave correctly.

IoC without using DI, for example would be the Template pattern because the implementation can only be changed through sub-classing.

DI Frameworks are designed to make use of DI and can define interfaces (or Annotations in Java) to make it easy to pass in the implementations.

IoC Containers are DI frameworks that can work outside of the programming language. In some you can configure which implementations to use in metadata files (e.g. XML) which are less invasive. With some you can do IoC that would normally be impossible like inject an implementation at pointcuts.