Closed feodormak closed 6 years ago
Hey @feodormak, can you please comment the code that you're trying to run?
The code i was trying to run is
@IBAction func saveToAppSupp(_ sender: UIButton) {
let image = UIImage(named: "apple.png")
do {
try Disk.save(image, to: .applicationSupport, as: "apple.png")
}
catch { }
}
At runtime, it gives this error,
fatal error: Optional<UIImage> does not conform to Encodable because UIImage does not conform to Encodable.: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65.2/src/swift/stdlib/public/core/Codable.swift, line 3962
2017-10-27 14:44:56.078139+0800 boxApp[986:26400] fatal error: Optional<UIImage> does not conform to Encodable because UIImage does not conform to Encodable.: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65.2/src/swift/stdlib/public/core/Codable.swift, line 3962
Not sure if it's related, by when I Alt-Control over the function, this is what I get, and I am guessing that's why it's throwing the 'does not conform to Encodable' error.
Ok, apologies. Solved it. My noob mistake. The UIImage optional needs to be unwrapped to be used. Thanks!
Glad you figured it out :^)
I've tried to save an image as shown in your example, and the app always crashes with,
fatal error: Optional does not conform to Encodable because UIImage does not conform to Encodable
When I hold down Alt/Option and hover over my declaration, it shows the declaration for the Codable initializer even though I've used Disk.save with an UIImage.
Any ideas if I am using it wrong?