Post

Replies

Boosts

Views

Activity

Reply to Using PencilKit in Swift. What is the best way to save PKDrawing into a remote database? How to serialize it?
Hi, I try to load an png image in my PKDrawing, but it seems that init(data:) doesn't work like expected. Here is my code var base64 = sign!.replacingOccurrences(of: "data:image/png;base64,", with: "") base64 = base64.replacingOccurrences(of: "\r", with: "") base64 = base64.replacingOccurrences(of: "\n", with: "") guard let dataDecoded = Data(base64Encoded: base64, options: .ignoreUnknownCharacters) else { return } do { self.canvasView.drawing = try PKDrawing.init(data: dataDecoded) } catch { print("Error loading drawing object") } No error catched but nothing in my canvas. I also tried append(_ :PKDrawing) but it's the same. Any ideas? What is my mistake? I work in SwiftUI.
Dec ’21