Estimating the size of the AGSExportTileCacheTask

346
1
02-17-2020 08:58 AM
RafayFarooq
New Contributor

I am trying to implement an offline map feature for my app. I was able to create AGSExportTileCacheTask that is returning parameters based on MinScale, MaxScale, and BaseMap URL but when I try to start the estimeTileCacheSizeJob, I am not hitting any breakpoint on either completion or job status change handler. Is there a way to know if the job has been submitted successfully on the server and approx how much time does it take for the job to return the size? Below is the code I am using

offlineMapExportTask = AGSExportTileCacheTask(url: offlineBaseMapURL)

            offlineMapExportTask?.exportTileCacheParameters(withAreaOfInterest: overlayEnvelope, minScale: minScale, maxScale: maxScale) {

                [weak self] (params: AGSExportTileCacheParameters?, error: Error?) in

                guard let self = self else {

                    return

                }

                if let error = error {

                    completion(error)

                } else if let params = params {

                    self.exportTilesUsingParameters(params)

                }

            }

private func exportTilesUsingParameters(_ params: AGSExportTileCacheParameters) {

        self.estimateTileCacheSizeJob = self.offlineMapExportTask?.estimateTileCacheSizeJob(with: params)

        estimateTileCacheSizeJob?.start(statusHandler: { (jobStatus) in

            print(jobStatus)

        }, completion: { (result, error) in

            if let error = error {

               print(error)

            }

})

I am not sure if I am missing something. Any tips and guidelines to debug this would be appreciated.

0 Kudos
1 Reply
RyanOlson1
Esri Contributor

Usually when completions aren't called it's because the object that the async method was on was deallocated. In your case that would be `offlineMapExportTask`. Can you verify that the object is around for the lifetime of the async call?

0 Kudos