IosModelDownloadDelegate

private class IosModelDownloadDelegate(val destinationPath: String, val onProgress: (Int) -> Unit, val onBytesReceived: (Long) -> Unit, val onComplete: (Result<Unit>) -> Unit) : NSObject, NSURLSessionDownloadDelegateProtocol(source)

NSURLSession delegate that converts native progress callbacks into app download state callbacks.

Author

Dmitriy Moroz

Parameters

destinationPath

Temporary destination where NSURLSession output is moved before finalization.

onProgress

Emits integer percent progress when iOS reports total expected byte count.

onBytesReceived

Emits every positive byte delta for traffic statistics.

onComplete

Completes the callbackFlow with success or a user-visible download error.

Constructors

Link copied to clipboard
constructor(destinationPath: String, onProgress: (Int) -> Unit, onBytesReceived: (Long) -> Unit, onComplete: (Result<Unit>) -> Unit)

Properties

Link copied to clipboard
private var completed: Boolean
Link copied to clipboard
Link copied to clipboard
expect val description: String?
Link copied to clipboard
private val destinationPath: String
Link copied to clipboard
expect val hash: NSUInteger
Link copied to clipboard
private var lastPercent: Int
Link copied to clipboard
private val onBytesReceived: (Long) -> Unit
Link copied to clipboard
private val onComplete: (Result<Unit>) -> Unit
Link copied to clipboard
private val onProgress: (Int) -> Unit
Link copied to clipboard
expect val superclass: ObjCClass?

Functions

Link copied to clipboard
expect open override fun class(): ObjCClass?
Link copied to clipboard
private fun complete(result: Result<Unit>)

Completes the delegate exactly once even when NSURLSession reports multiple terminal events.

Link copied to clipboard
expect open override fun conformsToProtocol(aProtocol: Protocol?): Boolean
Link copied to clipboard
expect open fun copy(): Any?
Link copied to clipboard
expect open fun debugDescription(): String?
Link copied to clipboard
expect open override fun description(): String?
Link copied to clipboard
expect open fun doesNotRecognizeSelector(aSelector: COpaquePointer?)
Link copied to clipboard
expect open fun finalize()
Link copied to clipboard
expect open fun forwardingTargetForSelector(aSelector: COpaquePointer?): Any?
Link copied to clipboard
expect open fun forwardInvocation(anInvocation: NSInvocation?)
Link copied to clipboard
expect open override fun hash(): NSUInteger
Link copied to clipboard
expect open fun init(): NSObject?
Link copied to clipboard
expect open override fun isEqual(object: Any?): Boolean
Link copied to clipboard
expect open override fun isKindOfClass(aClass: ObjCClass?): Boolean
Link copied to clipboard
expect open override fun isMemberOfClass(aClass: ObjCClass?): Boolean
Link copied to clipboard
expect open override fun isProxy(): Boolean
Link copied to clipboard
expect open fun methodForSelector(aSelector: COpaquePointer?): IMP?
Link copied to clipboard
expect open fun methodSignatureForSelector(aSelector: COpaquePointer?): NSMethodSignature?
Link copied to clipboard
expect open fun mutableCopy(): Any?
Link copied to clipboard
expect open override fun performSelector(aSelector: COpaquePointer?): Any?
expect open override fun performSelector(aSelector: COpaquePointer?, withObject: Any?): Any?
expect open override fun performSelector(aSelector: COpaquePointer?, withObject: Any?, _withObject: Any?): Any?
Link copied to clipboard
expect open override fun respondsToSelector(aSelector: COpaquePointer?): Boolean
Link copied to clipboard
expect open override fun superclass(): ObjCClass?
Link copied to clipboard
open override fun URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL: NSURL)
open override fun URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError: NSError?)
open override fun URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData: Long, totalBytesWritten: Long, totalBytesExpectedToWrite: Long)
expect open fun URLSession(session: NSURLSession, didBecomeInvalidWithError: NSError?)
expect open fun URLSession(session: NSURLSession, didReceiveChallenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Unit)
expect open fun URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset: int64_t, expectedTotalBytes: int64_t)
expect open fun URLSession(session: NSURLSession, taskIsWaitingForConnectivity: NSURLSessionTask)
expect open fun URLSession(session: NSURLSession, didCreateTask: NSURLSessionTask)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, needNewBodyStream: (NSInputStream?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didReceiveInformationalResponse: NSHTTPURLResponse)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didFinishCollectingMetrics: NSURLSessionTaskMetrics)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, needNewBodyStreamFromOffset: int64_t, completionHandler: (NSInputStream?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didReceiveChallenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, willBeginDelayedRequest: NSURLRequest, completionHandler: (NSURLSessionDelayedRequestDisposition, NSURLRequest?) -> Unit)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData: int64_t, totalBytesSent: int64_t, totalBytesExpectedToSend: int64_t)
expect open fun URLSession(session: NSURLSession, task: NSURLSessionTask, willPerformHTTPRedirection: NSHTTPURLResponse, newRequest: NSURLRequest, completionHandler: (NSURLRequest?) -> Unit)
expect open fun URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession)