我尝试按照以下教程中的说明实现 NSURLProtocol:http ://www.raywenderlich.com/76735/using-nsurlprotocol-swift
在 iOS8 上一切正常,但在 iOS7 中我在 startLoading() 中遇到运行时错误。
override func startLoading() {
var newRequest = self.request.copy() as NSMutableURLRequest //<- this line fails
NSURLProtocol.setProperty(true, forKey: "MyURLProtocolHandledKey", inRequest: newRequest)
self.connection = NSURLConnection(request: newRequest, delegate: self)
}
错误:WebCore:CFNetwork Loader(10):EXC_BREAKPOINT
有人成功实现了 NSURLProtocol 吗?谢谢!