MapleBacon.DiskStorage 3.0.0 升级后不再授予图像访问权限:为什么?

MapleBacon.DiskStorage no longer granting access to images after 3.0.0 upgrade: why?

根据 https://github.com/zalando/MapleBacon 的文档,我创建了以下内容,它在 Swift 2.3 中工作:

import MapleBacon

fileprivate let
_manager: ImageManager
, _storage: DiskStorage
, _stopwatch: Stopwatch
, _urlsLoading: [ String ]

required init ()
{
    _manager = ImageManager.sharedManager
    _storage = DiskStorage( name: "MyStorageName" )
    _stopwatch = Stopwatch()
    _urlsLoading = []
}

func loadImageBy ( Url url: String )
{
    guard let nsurl = URL( string: url ) else { return }

    _urlsLoading.append( url )

    _manager.downloadImage(
        atUrl: nsurl
        , cacheScaled: true
        , imageView: nil
        , storage: _storage
        , completion:
        {
            [ unowned self ] ( image, error ) -> Void in
            self._stopwatch.startWith( 
                Delay: 0.02
                , ForListener: self._onStopwatchComplete 
            )
        }
    )
}

我发现使用我自己的 Stopwatch 组件强制延迟 0.02 启用 MapleBacon.DiskStorage 以通过其 image( forKey: ) 方法使图像可用:

fileprivate lazy var _onStopwatchComplete: ( String, Any? ) -> Void =
{
    [ unowned self ] ( key: String, data: Any? ) -> Void in

    var url: String, imageCount = 0

    // loop through urls of images being loaded
    for _ in 0..<self._urlsLoading.count
    {
        url = self._urlsLoading[ imageCount ]

        // image found
        if let img = self._storage.image( forKey: url )
        {
            print( img )
            // remove from list of urls of images being loaded and...
            self._urlsLoading.remove( at: imageCount )
        }

        // image not found: continue waiting
        else
        {
            imageCount += 1
        }
    }

    self._stopwatch.stop()
}

使用 Swift 3.0 版的 MapleBacon,即使延迟 5 秒也不会产生对 _storage 中图像的引用,就像 Swift 2.3 版一样, 也没有在 completion: ( image, error ) -> 闭包中。

使用 3.0.0 版本的 MapleBacon,需要做什么才能成功地从 DiskManager 存储和检索图像?

感谢您[至少阅读]。

PS:我没有创建 MapleBacon 标签所需的分数。如果有人能做到,那就太好了,谢谢。

MapleBacon 的贡献者 Jan Gorman 将此识别为 MapleBacon 3.0.0 中的一个真正错误,并上传了一个修复程序(此处发布线索:https://github.com/zalando/MapleBacon/issues/38)。在 Swift 2.3 中有效的代码现在在 Swift 3.0 中也有效。