代码之家  ›  专栏  ›  技术社区  ›  Prashant Tukadiya

无法理解崩溃日志部分应用转发器关闭#1

  •  0
  • Prashant Tukadiya  · 技术社区  · 7 年前

    我得到以下冰球应用程序崩溃

    Thread 0 Crashed:
    0   App                         0x000000010302e7f8 partial apply forwarder for closure #1 (__C.UIImage?, [Swift.AnyHashable : Any]?) -> () in static App.ImageLoader.image(from: __C.PHAsset, size: __C_Synthesized.CGSize, success: (__C.UIImage) -> ()) -> () (PhotoLibraryImageLoader.swift:28)
    1   App                         0x000000010302d958 reabstraction thunk helper from @escaping @callee_guaranteed (@owned __C.UIImage?, @owned [Swift.AnyHashable : Any]?) -> () to @escaping @callee_unowned @convention(block) (@unowned __C.UIImage?, @unowned __C.NSDictionary?) -> () (PhotoLibraryImageLoader.swift:0)
    2   Photos                               0x00000001917c89cc __84-[PHImageManager requestImageForAsset:targetSize:contentMode:options:resultHandler:]_block_invoke.1505 + 816
    

    在PhotoLibraryImageLoader.swift文档

    static func image(from assest:PHAsset,size:CGSize,success:@escaping (_ image:UIImage) -> Void) {
            let option = PHImageRequestOptions()
            option.isSynchronous = false
            option.deliveryMode = .highQualityFormat
            PHImageManager.default().requestImage(for: assest, targetSize: size, contentMode: .aspectFill, options: option) { (image, attributes) in
                success(image!) // Crash line  PhotoLibraryImageLoader.swift:28
            }
     }
    

    如果有问题可供选择( image! )崩溃日志应该是不同的(比如意外发现nil..)

    这是什么意思

    2 回复  |  直到 7 年前
        1
  •  1
  •   Prashant Tukadiya    7 年前

    不可用的映像导致崩溃(需要从服务器下载)

    为此,在选项中添加一行

        option.isNetworkAccessAllowed = true
    

    希望对别人有帮助

        2
  •  0
  •   Adarsh V C    7 年前

    if let wSelf = self {
        println("i have image now")
        // do what you want with the image/self
    }