gpt4 book ai didi

swift - 是线程 1 : signal SIGABRT always a connection issue (cgimagedestinationfinalize)

转载 作者:行者123 更新时间:2023-11-30 12:36:54 24 4
gpt4 key购买 nike

使用这个 block ,我的应用程序每次尝试都会崩溃

CGImageDestinationFinalize(gifDest!)

阻止

func createGIF(with images: [CGImage], data: Data, loopCount: Int, frameDelay: Double) -> Data {
print("()createGIF.HandHistoryTableVC")
let gifDest = CGImageDestinationCreateWithData(data as! CFMutableData, kUTTypeGIF, images.count, nil)
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]]
CGImageDestinationSetProperties(gifDest!, fileProperties as CFDictionary?)
let frameProperties = [(kCGImagePropertyGIFDictionary as String): [(kCGImagePropertyGIFDelayTime as String): frameDelay]]
for img in images {
CGImageDestinationAddImage(gifDest!, img, frameProperties as CFDictionary?)
}
print("GIF in Progress")
CGImageDestinationFinalize(gifDest!)
print("gifMade")
return data;
}

错误报告

enter image description here我不知道这次事故的原因。所有关于“线程 1:信号 SIGABRT”的研究似乎都说这是一个连接问题,但如果我注释掉 CGImageDestinationFinalize(),我的整个应用程序工作正常

最佳答案

func createGIF(with images: [CGImage], data: CFMutableData, loopCount: Int, frameDelay: Double) -> Data {
print("()createGIF.HandHistoryTableVC")
let gifDest = CGImageDestinationCreateWithData(data, kUTTypeGIF, images.count, nil)
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]]
CGImageDestinationSetProperties(gifDest!, fileProperties as CFDictionary?)
let frameProperties = [(kCGImagePropertyGIFDictionary as String): [(kCGImagePropertyGIFDelayTime as String): frameDelay]]
for img in images {
CGImageDestinationAddImage(gifDest!, img, frameProperties as CFDictionary?)
}
print("GIF in Progress")
CGImageDestinationFinalize(gifDest!)
print("gifMade")
return data as Data;
}

使用 CFMutableData 初始值设定项

CFDataCreateMutable(kCFAllocatorDefault, 0)

解决了这个问题。

关于swift - 是线程 1 : signal SIGABRT always a connection issue (cgimagedestinationfinalize),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42753496/

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