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 )