by Ossi Hanhinen, @ohanhi
with the support of Futurice 💚.
Licensed under CC BY 4.0.
// When using Charles, the network requests will always fail unless you can bypass ATS. | |
public class NetworkEnabler: NSObject, NSURLSessionDelegate { | |
public func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) { | |
completionHandler(.UseCredential, NSURLCredential(trust: challenge.protectionSpace.serverTrust!)) | |
} | |
} | |
// Then later when making a request: | |
let enabler = NetworkEnabler() | |
let session = NSURLSession(configuration: NSURLSession.sharedSession().configuration, delegate: enabler, delegateQueue: nil) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.