General Flashcards
How to get .p12?
tylko osoba która go tworzy ma klucz prywatny i to ona musi Ci go dać z własnego keychaina
Coordinator key points
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.
Avoid making real networking calls in your unit tests by mocking
URLSession and URLSessionDataTask.
Do TDD for GET requests easily by breaking them into several smaller tasks:
calling the right URL, handling HTTP status errors, handling valid and invalid responses.
How to test Networking Client?
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
Save completion vs call completion after another request
Call completion you use when you are also waiting for some completion
save completion to pass data later in your test
There are two ways you can create a mock network client in Swift:
- 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. - 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.
you should create a mock network client using a
protocol instead of subclassing-and-overriding.
What you should add to your network client protocol?
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.
Testing flow
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
There are two different types of cryptography
symmetric cryptography, and asymmetric cryptography.
“use Keychain Access to export your identity, and you wanted to format it in a .cer (certificate) format,
you’d only be exporting the public key.
to properly export the full identity from keychain
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
What are Entitlements
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.
Attach debugger entitlement
get-task-allow entitlement
What provisioning profiles include?
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
Certificate it’s like
public key in security
Public key cryptography is based on the premise that there are two keys
: one key for encrypting, and one key for decrypting.
Public key
public key is something that you can share freely.
Private key
You can think of the private key like an actual key that you have to protect and keep safe
Dynamic frameworks vs static frameworks
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.
An initializer must assign a value to every single stored property that
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.