Monday, July 29, 2024
HomeiOS Developmentios - Is it true that there is no such thing as...

ios – Is it true that there is no such thing as a approach in any respect to subclass URLSessionDataTask, and in that case is there a approach so as to add an related property?


I’ve all the time wished to do one thing like

class URLSessionDataTask_Plus: URLSessionDataTask {
    
    var obs: NSKeyValueObservation? = nil
    // retailer the progress observer there 
}

which might be very handy. I do not know tips on how to do it. If as a substitute you do one thing like

///URLSessionDataTask, plus extra!
class URLSessionDataTask_Plus {
    
    var job: URLSessionDataTask? = nil
    var obs: NSKeyValueObservation? = nil
}

there’s actually no benefit, as you anyway need to nonetheless keep that variable externally (or keep that complete object externally).

Progress observations are an actual nuisance to hold on to as you by no means know what number of you will want or the place.

Is there some technique to obtain this idea? ->

class URLSessionDataTask_Plus: URLSessionDataTask {
    
    var obs: NSKeyValueObservation? = nil
    // retailer the progress observer there 
}

(I word that the identical applies even in case you use the futuristic async calls .. https://stackoverflow.com/a/78804162/294884 )



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments