It's a little bit late to reply but I think the error stems from trying to access the self inside a static func. Instead of declaring writeToPhotoAlbum as a static, declare it without static keyword and call it after creating an instance of ImageDownloader.
Like:
import Foundation
import UIKit
class ImageDownloader: NSObject {
func writeToPhotoAlbum(imageUrl: String) {
// ...
}
@objc func saveCompleted(
_ image: UIImage,
didFinishSavingWithError error: Error?,
contextInfo: UnsafeRawPointer)
{
// ...
}
}
Then,
var imageDownloader: ImageDownloader?
imageDownloader = ImageDownloader()
imageDownloader?.writeToPhotoAlbum(imageUrl: imgUrl)
These may not be directly compilable but it may give a basic idea about the problem.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: