-1

在此处输入图像描述

我很确定这就是为什么我的完成块没有在这里调用的原因:

    resourceRequest = NSBundleResourceRequest(tags: Set(["preview"]))
    resourceRequest?.beginAccessingResources { [weak self] downloaded in //not called


        // here I do what I need with this and at the end I call      
        // self?.resourceRequest?.endAccessingResources()
        
    }

我已经清理并重新启动了 Xcode,也重新启动了 iPhone 和 Macbook。没有任何帮助。我怎样才能在这里清除它?

编辑

我打印了一些进度属性的信息:

print(resourceRequest?.progress.isCancelled) //false
print(resourceRequest?.progress.isPaused) //false
print(resourceRequest?.progress.isFinished) //false
print(resourceRequest?.progress.isIndeterminate) //false
print(resourceRequest?.progress.localizedDescription) //0% completed
print(resourceRequest?.progress.isCancellable) //true

但是当我打电话时cancel()没有任何改变......

如何拒绝、取消或恢复该请求?

当我打印进度时,我有:

<NSProgress: 0x280cd1720> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 1
4

2 回答 2

0

希望你检查这个注意

在访问标记有请求管理的标签的任何资源之前,您必须调用此方法或有条件地BeginAccessingResources(completionHandler:)

func conditionallyBeginAccessingResources(completionHandler: @escaping (Bool) -> Void)

正如Apple建议在下面链接的一些复选标记之前做的那样

请检查此检查点

于 2020-08-27T13:36:59.017 回答
0

设备上的磁盘是否已满?该文档提供了一个方便的小片段来注册通知并检查它。

在这里复制它:

清单 4-11 注册 NSBundleResourceRequestLowDiskSpaceNotification 通知


    // Register to call self.lowDiskSpace when the notification occurs
    [[NSNotificationCenter defaultCenter]
        addObserver:self
           selector:@selector(lowDiskSpace:)
               name:NSBundleResourceRequestLowDiskSpaceNotification
             object:nil
    ];

    // Notification handler for low disk space warning
    -(void)lowDiskSpace:(NSNotification*)theNotification
    {
        // Free the lower priority resource requests
        for (NSBundleResourceRequest *atRequest in self.lowPriorityRequests) {
            // End accessing the resources
            [atRequest endAccessingResources];
        }
     
        // clear lowPriorityRequests preventing multiple calls to endAccesingResource
        [self.lowPriorityRequests removeAllObjects];
    }
于 2020-08-27T18:10:43.623 回答