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 12-09-2011, 01:54 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 5
badnewsbeers is on a distinguished road
Default Switch views and retain data

Hi,
I'm writing a procedure based application where the user navigates through a set of views and makes changes on them (toggle switches, buttons, etc). All is well and good, except when the user navigates backwards through the views and then tries to move forward again - all the views are reset.

I am wondering if there is a way to set up my software such that anytime a user leaves a view, all of its data is retained until either the user returns to that view and modifies it or the procedure is complete and the data saved.

Thanks in advance!
badnewsbeers is offline   Reply With Quote
Old 12-09-2011, 01:58 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Nope, not possible. Pay no attention to every single app ever made.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 02:02 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 5
badnewsbeers is on a distinguished road
Default

If you could point me in the right direction, that would be fantastic.
badnewsbeers is offline   Reply With Quote
Old 12-09-2011, 02:03 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Google for "iphone sdk how to save data?"
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 02:16 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 5
badnewsbeers is on a distinguished road
Default

Perhaps I wasn't very clear. I'm more concerned with the state of the objects on the screen. For example, if the user were to flip a few toggle switches, move a few screens, realize they made an error, and then go back to the beginning, I'd like those toggles to remain in the state they were in. Perhaps I just have a misunderstanding of MVC but I'm not sure how to make this happen. Basically I'd like a way to prevent the views from popping off the stack as the user backtracks through the application. If you're saying the same thing as me then I apologize and will keep looking.
badnewsbeers is offline   Reply With Quote
Old 12-09-2011, 02:18 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Do you have an M somewhere in this equation?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 02:21 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 5
badnewsbeers is on a distinguished road
Default

Not specifically defined, I was doing it within the views. Assuming this is the wrong way to approach things. Back to the books.
badnewsbeers is offline   Reply With Quote
Old 12-09-2011, 02:22 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You can't rely on views for storage. Off-screen views are routinely unloaded to free up memory. Capture whatever information needs to be saved when the view goes off screen. Restore it when the view comes back on screen.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-09-2011, 02:39 PM   #9 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by badnewsbeers View Post
Not specifically defined, I was doing it within the views. Assuming this is the wrong way to approach things. Back to the books.


Here's what to do:

Set up a data container singleton. At launch, create all your view controllers and save pointers to them in the singleton. That will cause you view controllers to stick around. When you need to push a view controller, fetch the existing view controller from the singleton and push it.

In each view controller's viewDidLoad method, set all the view settings the way you want them to be, using the view controller's instance variables, or a separate model object, if you have it separated out.

Make your view controllers respond to a low memory warning by releasing everything they can reproduce.

Your view controllers will stick around for the life of your application. Their views could be unloaded at any point when they are not frontmost, which is why you write code in your viewDidLoad that completely sets up your views.
__________________
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 online now   Reply With Quote
Old 12-09-2011, 03:41 PM   #10 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 5
badnewsbeers is on a distinguished road
Default

Thanks very much guys, I appreciate it. That's exactly what I'll do.
badnewsbeers is offline   Reply With Quote
Reply

Bookmarks

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: 413
13 members and 400 guests
7twenty7, AppsBlogger, David-T, Duncan C, EvilElf, HemiMG, heshiming, iekei, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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