Appdelegate vs. UIViewcontroller

I was wondering whether it would be better to use the appdelegate or a viewcontroller as the state manager for my game. I'm having trouble deciding because both have their advantages. The appdelegate would be much more easily accessible as you can get a reference to it anywhere, and that would be useful inside the game state classes when you wanted to tell the state manager to change states. However, using a viewcontroller would also have some advantages. I am most likely going to also use viewcontrollers as my game states, so if I used another viewcontroller as my state manager I may be able to present game states in a modal transition which would be useful. I also noticed that the flipside project template in xcode uses a rootviewcontroller as its state manager, so is there any reason why that is used instead of the appdelegate? However, one problem with a viewcontroller state manager is that the game states would need a reference to the state manager in order to tell it to change states (or is this when I should use delegation?). I am leaning towards using the appdelegate as the state manager as that would be a lot easier to change states with from inside a state itself, and if I created some transitions by using Core Animation then modal transitions wouldn't be needed that much. However, I would very much like some input from you guys on which would offer advantages, or any other ideas.

There really are a zillion different ways you can do this. The advantages between several approaches can be completely subjective.

If you made the topmost view controller the "state manager", there's no reason you can't access it from anywhere in the project either. At the simplest, the app delegate would have a reference to it and object in the class can get a reference through it that way. Use a macro to make access prettier if you want.

You can also use a third object, a singleton whose only job is to manage the states, their modality etc. You could have the state manager know about the topmost view controller, or not. In one approach, the state manager would push the states/view controllers into the top one as part of switching states, or you could use one of the delegate/notification/KVO approaches and have the topmost vc do the push/popping based on those messages.

Lots of different ways. If what you're doing feels really wrong, then it probably is. If it seems slightly awkward but so would every other approach, you're fine.

OneSadCookie: I suppose, it's just that I thought you were more talking about the game logic than the state management. Sorry though.

SethWillits: Okay, thanks. What I have in mind right now seems like a good way to go about it, so I'm going to stick to it. Like you said, it's probably a lot more subjective than I thought, and there are too many ways to really have a best method. And really, whatever works, works.

I guess my game is just so simple that I haven't run into any issues...I just used one if statement for game running/not running. Everything else is handled by scenes and data is passed between scenes via NS User defaults.