Fetching CKAsset Image From CloudKit is Very Slow

前端 未结 2 630
面向向阳花
面向向阳花 2021-02-05 19:42

I am using CloudKit as a server backend for my iOS application. I\'m using it to house some relatively static data along with a handful of images(CKAsset). I ran into a problem

2条回答
  •  执笔经年
    2021-02-05 20:19

    There seems to be something slowing down your main thread which introduces a delay in executing the capture block of your dispatch_async call. Is it possible that your code calls this record fetching function multiple times in parallel ? This would cause the NSData(contentsOfURL: asset.fileURL) processing to hog the main thread and introduce cumulative delays.

    In any case, if only as a good practice, loading the image with NSData should be performed in the background and not on the main thread.

提交回复
热议问题