Last active
November 21, 2016 19:03
-
-
Save joemasilotti/c1a2ad4fd95411f445f0 to your computer and use it in GitHub Desktop.
Trying to mock NSURLConnection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol URLSessionDataTaskProtocol { | |
| func resume() | |
| } | |
| extension NSURLSessionDataTask: URLSessionDataTaskProtocol { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typealias DataTaskResult = (NSData?, NSURLResponse?, NSError?) -> Void | |
| protocol URLSessionProtocol { | |
| func dataTaskWithURL(url: NSURL, completionHandler: DataTaskResult) -> URLSessionDataTaskProtocol | |
| } | |
| extension NSURLSession: URLSessionProtocol { } // ERROR: Type 'NSURLSession' does not conform to protocol 'URLSessionProtocol' |
Author
@briancroom @joemasilotti Do you guys have Swift 3 version of this? I'm getting a Type 'URLSession' does not conform to protocol 'URLSessionProtocol' on the extension URLSession: URLSessionProtocol line.
Also getting Expressions are not allowed at the top level on useSession( line.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does work, thanks @briancroom!