gpt4 book ai didi

ios - swift - UIImageWriteToSavedPhotosAlbum 导致 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-28 07:03:37 28 4
gpt4 key购买 nike

我正在相机胶卷中保存图像。但是完成后,我应该引用数据库中的图像。逻辑很简单

class MyDownloader{
let db : DbHelper = DbHelper.sharedInstance

func downloadFileFromServer(){
let urlString = "http://any-image.jpg"
let url = NSURL(string: urlString)
let data = NSData(contentsOfURL: url!)
let image = UIImage(data: data!)
if(image == nil){
println("no downloaded image")
}
else{
// THIS WORKS WITH NO ERRORS
--> --> UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

// THIS NEVER WORKS
--> --> UIImageWriteToSavedPhotosAlbum(image, self, "image:didFinishSavingWithError:contextInfo:", nil)
}
}

func image(image: UIImage, didFinishSavingWithError error: NSErrorPointer, contextInfo:UnsafePointer<Void>) {
if error != nil {
// error feedback goes here
}
else{
// save db reference here
}
}
}

下面的方法

UIImageWriteToSavedPhotosAlbum(image, self, "image:didFinishSavingWithError:contextInfo:", nil)

总是返回 EXC_BAD_ACCESS

最佳答案

您可能应该使 MyDownloader 继承自 NSObject,因为 selector 是 Objective-C 运行时的一部分。

关于ios - swift - UIImageWriteToSavedPhotosAlbum 导致 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31412873/

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