Posts
- Get link
- X
- Other Apps
Popular Posts
escaping closure and closure
Closures are self-contained blocks of functionality that can be passed around and used in your code. let greeting:(String) -> () = { name in print("Hi, \(name)!") } birthday("Bebo") An escaping closure is a closure that’s called after the function it was passed to returns. In other words, it outlives the function it was passed to. A non-escaping closure is a closure that’s called within the function it was passed into, i.e. before it returns.
Certificate pinning and Alamofire
1. Alamofire and URLSession. both help you to make network requests in Swift. Main advantage for Alamofire: Certificate pinning . It can take some time to sort this out and build this yourself. Asymmetric cryptography : The second phase uses public-key cryptography or asymmetric cryptography . This is a cryptographic system that uses pairs of keys: Public keys, which are widely disseminated and private keys, which only the owner knows. The third phase uses symmetric-key cryptography , where you use the same key for both encryption of plaintext and decryption of ciphertext. In other words, you configure the app to reject all but one or a few predefined certificates or public keys. Whenever the app connects to a server, it compares the server certificate with the pinned certificate(s) or public key(s). If and only if they match, the app trusts the server and establishes the connection. You usually add a service’s certificate or public key a...
MVVM and MVC in swift
MVC: View is supposed to be inactive and only displays prepared data on demand. Model : It represents simple data. Controller should work on the Model data to prepare it for the Views , which then display that data. View is also responsible for notifying the Controller about any actions, such as user touches. UIViewController is supposed to be a Controller in the MVC pattern, MVVM: The Model View ViewModel (MVVM) is an architectural pattern used in software engineering. Models hold application data / Content. They’re usually structs or simple classes. Views display visual elements and controls on the screen. They’re typically UIView and UIViewController . xib and storyboards View models transform model information into values that can be displayed on a view. They’re usually classes, so they can be passed around as references. ViewModel hides all asynchronous networ...