Application crashes when calling CGContextRestoreGState


#1

In the gold challenge, we need to call CGContextRestoreGState for clearing the clipping path and drop shadow. When I try to do this, though, the app crashes with this message:

Application windows are expected to have a root view controller at the end of application launch

It runs fine if I don’t call that method. Just curious what I am supposed to set as the root view controller when the base app we built during the chapter doesn’t have one.


#2

The message you have highlighted has nothing to do with the crash you are seeing. It is expected to see this message at this stage of the book (and it is explained a little later).
Perhaps you should share your code so we can see what else the problem might be.


#3

Nevermind, I figured it out. I had not called CGContextSaveGState, so it had no context to restore!

Thanks. Your comment did help me find the correct error message.