Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: ViewWillAppear vs ViewDidAppear to load drawing #60

Closed
ramjyroo opened this issue Jun 18, 2020 · 3 comments
Closed

Question: ViewWillAppear vs ViewDidAppear to load drawing #60

ramjyroo opened this issue Jun 18, 2020 · 3 comments

Comments

@ramjyroo
Copy link

I have stored the JSON string of the drawing and want to reload it back into DrawingView.

func loadScratchText() {
        let jsonDecoder = JSONDecoder()
        let scratchText = self.viewModel.scratchText
        print("scratchText: \(scratchText)")
        guard let jsonData = scratchText.data(using: .utf8) else {
            return
        }
        guard let drawing = try? jsonDecoder.decode(Drawing.self, from: jsonData) else {
            print("Unable to load scratch json")
            return
        }
        self.drawingView.drawing = drawing
        print(drawingView.drawing.shapes)
        print("")
    }

If I call this function in viewWillAppear - it prints the shapes but the drawing is NOT visible. But when I use viewDidAppear - it does nicely render back the drawing.

Is this expected behavior?

thanks
Ram

@stevelandeyasana
Copy link
Collaborator

You're probably seeing this because I forgot to merge #58 and do a release. :-) Would you mind trying again with the latest master branch?

@ramjyroo
Copy link
Author

Sure thanks so much!

@ramjyroo
Copy link
Author

Thanks a bunch !! It is definitely working as expected with the latest master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants