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 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 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@briancroom @joemasilotti Do you guys have Swift 3 version of this? I'm getting a
Type 'URLSession' does not conform to protocol 'URLSessionProtocol'
on theextension URLSession: URLSessionProtocol
line.Also getting
Expressions are not allowed at the top level
onuseSession(
line.