-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有没有好的方案,把URLSessionDataDelegate更多的协议实现暴露出来 #1620
Conversation
我可能更倾向于把 |
|
||
|
||
/// You could set the extra handler before a downloading task starts. | ||
public weak var extraSessionDelegateHandler:URLSessionDataDelegate? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public weak var extraSessionDelegateHandler:URLSessionDataDelegate? { | |
public var extraSessionDelegateHandler:URLSessionDataDelegate? { |
For a getter/setter, there should be no need to mark it as weak
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,多谢!
func getExtraHandler() -> URLSessionDataDelegate? { | ||
return extraHandler | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to remove these methods and make extraHandler
to internal
, so we can just use the property without this boilerplate method calling.
Nice! Thank you. |
It seems that these changes cause an error while loading.
I am not sure what is happening now, but reverting these changes can solve the issue. I am going to revert it and tag a patch version. I will also keep digging to see what is the problem/ |
extraHandler?.urlSession?(session, dataTask: dataTask, didBecome: downloadTask) | ||
} | ||
func urlSession(_ session: URLSession, task: URLSessionTask, needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) { | ||
extraHandler?.urlSession?(session, task: task, needNewBodyStream: completionHandler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you implements the URLSessionDelegate method with completionBlock, you MUST
callback the handler, even if you don't have anything logic or nil extraHandler
here.
Same as other delegate methods.
有没有好的方案,把URLSessionDataDelegate更多的协议实现暴露出来
#1619
尝试一种方案。把URLSessionDataDelegate的其他协议方法,转发给业务方定制化处理