Model view advice needed

I have been stuck for so long on this and just can not get my head around the concept. I cant retain any data outside my first page on my apps, every-time I push to another view I lose all my data entered in text fields or any pictures imported. This means I have do do everything on the first page as that the only page that dosent destroy data as soon as i move away from it.. Surely there must be an easier way to do this...can someone point in the direction of a real beginners guide to model views, ive read Apple's documentation on this and find it no help at all, ive read up on here, and googled it and really am running out of ideas now

Answers


You are storing your data in the "Controller" level. Like the "View" level these come and go and are not a good place to store data long term. For longer term storage you want to keep you data down in the "Model". You can think of the three tiers this way.

  • The Model is the data (both volatile and permanent) and business rules.
  • The Controller is business rules, data interpretation to and from the view to the model, and user interaction management.
  • The View is for data output translation to meaningful information and user response interpretation.

Controllers (View Controllers) should only hold enough data to do their job and should never be considered to hold data any longer than is necessary. This is why the original view controller is the only one that keeps the data. It is the "Root" view controller and is not removed since it is the bottom view controller. When you "push" another view controller it is temporary because it will be "popped" back off and deallocated. Consider keeping your data (even for you root view controller) someplace else where you can get to it. Maybe in the App Delegate, Core Data, or a custom class that simply manages the data you need. Ensure your Model and Controller object can get to the data and you will have consistent data.


Need Your Help

Processing files make my program go into non-respongind mode. New Process or New thread?

c++ qt qt4 imagemagick qt-creator

I made an application using Qt where I manipulate Images using the Magick++ library.

Method invocation vs Reflection-Based Event System

java events reflection methods

Currently, I am trying to create a mod for a application. I've attempted to make it as dynamic as possible, by placing "hooks" inside the application. These hooks will be used to call/create which ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.