I'm trying to make a game with multiple interfaces. How can I do this?
Thanks!
You could create a timer that invokes a method that broadcasts an NSNotificationCenter notice.
It depends on what you're trying to do. If you need a timer that fires for each frame update on the screen, you should probably set up a timer for each view controller, start that timer when the view controller appears, and stop the timer when the view controller disappears.
You need to provide a better explanation of what you're trying to do in order to get anything other than very general advise.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
It would be a timer that starts on one interface, and keep going and displaying on every interface after it. So it's one timer that appears and tracks multiple interfaces.
It would be a timer that starts on one interface, and keep going and displaying on every interface after it. So it's one timer that appears and tracks multiple interfaces.
You said that. Your second post does not provide any more information. What is an "interface?" A different view controller?
What kind of timer? And what does the timer do? A timer doesn't "track interfaces", it invokes a method in a target object.
Do you need your multiple screens (view controllers) to all get the timer messages, even when they are not active, or just the front-most screen?
Is your app using view controllers, or is it using full-screen OpenGL? All these things matter in deciding the best approach to use.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
It's a quiz-type app, yes. Wouldn't it be too much for one view controller to put the equivalent of about 200 views in it? If not, how would I do it?
You probably don't want either 200 view controllers, or 200 views in a single view controller.
You probably want views that let you show a quiz question and all the possible answers. Your (single!) view controller would then install a question into the question view, install the possible answers into the answer views, and ask the user to pick an answer.
Duplicating a view controller to show another set of information in the same format is a common newbie mistake. Don't do that.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
You probably don't want either 200 view controllers, or 200 views in a single view controller.
You probably want views that let you show a quiz question and all the possible answers. Your (single!) view controller would then install a question into the question view, install the possible answers into the answer views, and ask the user to pick an answer.
Duplicating a view controller to show another set of information in the same format is a common newbie mistake. Don't do that.
Okay, then my question is 1) How do I have it switch views inside the single view controller (code)? and 2) How would I do the timer if I were to use multiple view controllers?
Okay, then my question is 1) How do I have it switch views inside the single view controller (code)? and 2) How would I do the timer if I were to use multiple view controllers?
You want a transition between views? What kind of transition? A push transition?
There are lots of ways to handle it. You could make a single view controller have 2 identical views, and swap between them using transitionFromView:toView:durationptions:complet ion: (you'd switch from view A to view B, and then from B back to A, replacing the content of the second view controller each time before displaying it.
You could create 2 view controllers and have them be managed as children of a third view controller, and use the transitionFromViewController:toViewController:dura tionptions:animations:completion method to switch between them. That would get a little more involved.
Probably the simplest would be to use Storyboards for your app, and make your view controller invoke a segue to link from one view controller to the next. Have the segue link back to the same view controller again.
No, by the way, I'm not going to write your code for you, unless you'd like to hire my company to do so.
I'm still not clear on what you're using the timer for. What does your timer do? How often does it fire? What would happen if you missed a single occurrence of the timer while a view transition was "in flight?"
Again, the details matter in deciding how to implement it.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
You want a transition between views? What kind of transition? A push transition?
There are lots of ways to handle it. You could make a single view controller have 2 identical views, and swap between them using transitionFromView:toView:durationptions:complet ion: (you'd switch from view A to view B, and then from B back to A, replacing the content of the second view controller each time before displaying it.
You could create 2 view controllers and have them be managed as children of a third view controller, and use the transitionFromViewController:toViewController:dura tionptions:animations:completion method to switch between them. That would get a little more involved.
Probably the simplest would be to use Storyboards for your app, and make your view controller invoke a segue to link from one view controller to the next. Have the segue link back to the same view controller again.
No, by the way, I'm not going to write your code for you, unless you'd like to hire my company to do so.
I'm still not clear on what you're using the timer for. What does your timer do? How often does it fire? What would happen if you missed a single occurrence of the timer while a view transition was "in flight?"
Again, the details matter in deciding how to implement it.
Okay... thanks... the timer counts up by one every second. It would make the timer inaccurate if it missed an occurrence... (it could be tenths of seconds instead of seconds)
Duncan what company? Im actually interested, you are very smart Im sure I can give you business someday with more advanced stuff I have no clue on how to do so far.
Duncan what company? Im actually interested, you are very smart Im sure I can give you business someday with more advanced stuff I have no clue on how to do so far.
Our company is called WareTo. We offer iOS and Mac consulting, and also do speculative development.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I'm using separate view controllers for each user interface.
If you are willing to make your app iOS 5 only, you could use storyboards, and use a push segue (or other type) to another instance of the same view controller. In Storyboards, each view controller is discarded when the new one is presented.
If you have 200 quiz pages, you need to avoid pushing 200 view controllers onto a navigation stack. You will almost certainly run out of memory and crash if you try that.
As far as setting up a timer that updates the current view controller, I'd suggest setting up the timer in your app delegate, with the delgate as the target.
Add a property "currentViewController" to the delegate.
Write a timer method in the delegate that updates a counter if needed, then sends a "timer fired" message to the "currentViewController".
That way your timer always talks to the same object, keeps track of the second counter, and notifies the current view controller each time it fires.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
If you are willing to make your app iOS 5 only, you could use storyboards, and use a push segue (or other type) to another instance of the same view controller. In Storyboards, each view controller is discarded when the new one is presented.
If you have 200 quiz pages, you need to avoid pushing 200 view controllers onto a navigation stack. You will almost certainly run out of memory and crash if you try that.
As far as setting up a timer that updates the current view controller, I'd suggest setting up the timer in your app delegate, with the delgate as the target.
Add a property "currentViewController" to the delegate.
Write a timer method in the delegate that updates a counter if needed, then sends a "timer fired" message to the "currentViewController".
That way your timer always talks to the same object, keeps track of the second counter, and notifies the current view controller each time it fires.