gpt4 book ai didi

ios - swift3 playground 无法获取路径的沙箱扩展

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:05:41 27 4
gpt4 key购买 nike

当我在 Playground 中创建 ImageView 时,它显示“沙盒扩展”错误。

let url = URL(string: "http://www.objc.io/images/covers/16.jpg")!
let image = CIImage(contentsOf: url)!
let imageView = UIImageView(frame: image.extent)
imageView.image = UIImage(ciImage: image )
PlaygroundPage.current.liveView = imageView

控制台消息:

2017-02-19 15:37:06.803 Chapter2[73915:885328] Failed to obtain sandbox extension for
path=/var/folders/3t/2tbk2tn96_v6_39rrjym3hsr0000gn/T/com.apple.dt.Xcode.pg/containers/
com.apple.dt.playground.stub.iOS_Simulator.Chapter2-8E7AB6A8-3EF4-47C0-BDA2-117817EA2934/Library/Caches/
com.apple.dt.playground.stub.iOS_Simulator.Chapter2-8E7AB6A8-3EF4-47C0-BDA2-117817EA2934. Errno:1

最佳答案

关键在于将 URLCache 设置为留在 playground 的沙箱中。

试试这个:

import Foundation
import PlaygroundSupport
import UIKit

URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)

func showObjIOImage() {
guard let url = URL(string: "http://www.objc.io/images/covers/16.jpg") else {
return
}
guard let image = CIImage(contentsOf: url) else {
return
}

let imageView = UIImageView(frame: image.extent)
imageView.image = UIImage(ciImage: image )
PlaygroundPage.current.liveView = imageView
}

showObjIOImage()

关于ios - swift3 playground 无法获取路径的沙箱扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42324845/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com