Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-01-2012, 12:40 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default How to create a timer accross multiple interfaces?

I'm trying to make a game with multiple interfaces. How can I do this?

Thanks!
rebello95 is offline   Reply With Quote
Old 02-01-2012, 12:50 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 80
itsaboutcode is on a distinguished road
Default

Quote:
Originally Posted by rebello95 View Post
I'm trying to make a game with multiple interfaces. How can I do this?

Thanks!
Can you tell more about it?
itsaboutcode is offline   Reply With Quote
Old 02-01-2012, 01:29 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by rebello95 View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-01-2012, 02:10 PM   #4 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

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.
rebello95 is offline   Reply With Quote
Old 02-01-2012, 02:32 PM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by rebello95 View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-01-2012, 02:45 PM   #6 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 174
dacapo is on a distinguished road
Default

Some things I can think of using this would be like a quiz app? Or some sort of speed reading app?

But I don't know why someone would use multiple view controllers for that, rather than just swap the contents within one view controller.

Just saying.
__________________
Follow me on Twitter: @dacaposoft
dacapo is offline   Reply With Quote
Old 02-01-2012, 02:46 PM   #7 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

Sorry. By "interface" I meant a view controller (.m, .h, and .xib files). I'm creating this app in Xcode.

The timer will be counting up and displaying the time on hopefully every view.

Like I said, I'm using separate view controllers for each user interface.
rebello95 is offline   Reply With Quote
Old 02-01-2012, 02:48 PM   #8 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

Quote:
Originally Posted by dacapo View Post
Some things I can think of using this would be like a quiz app? Or some sort of speed reading app?

But I don't know why someone would use multiple view controllers for that, rather than just swap the contents within one view controller.

Just saying.
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?
rebello95 is offline   Reply With Quote
Old 02-01-2012, 02:54 PM   #9 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by rebello95 View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-01-2012, 03:26 PM   #10 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
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?
rebello95 is offline   Reply With Quote
Old 02-01-2012, 06:12 PM   #11 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by rebello95 View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-01-2012, 10:51 PM   #12 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
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)
rebello95 is offline   Reply With Quote
Old 02-01-2012, 11:02 PM   #13 (permalink)
Registered Member
 
2WeeksToGo's Avatar
 
Join Date: Nov 2011
Posts: 227
2WeeksToGo is on a distinguished road
Default

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.
2WeeksToGo is offline   Reply With Quote
Old 02-02-2012, 06:30 AM   #14 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by 2WeeksToGo View Post
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-02-2012, 06:49 AM   #15 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by SpamBot5000
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.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


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.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.

Last edited by Rhade; 02-02-2012 at 08:09 AM.
Duncan C is offline   Reply With Quote
Old 02-02-2012, 11:40 AM   #16 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 130
rebello95 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
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.
Okay, thanks!
rebello95 is offline   Reply With Quote
Reply

Bookmarks

Tags
objective c, xcode, xcode interfaces, xcode timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 416
16 members and 400 guests
Atatator, chiataytuday, dre, FrankWeller, imac74, ipodphone, jeroenkeij, kukat, LunarMoon, MAMN84, n00b, PowerGoofy, QuantumDoja, Retouchable, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,675
Threads: 94,124
Posts: 402,909
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Retouchable
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0