save data on back navigation

Discussion in 'iOS Programming' started by jagatnibas, Oct 13, 2011.

  1. jagatnibas macrumors regular

    Jul 28, 2008
    i have a navigation bar based app, i was saving data while the view was going back by pressing back button successfully. now i need to display an alert and take confirmation to save. the problem i am facing is, when i press ok in alert, the view is popped up and data for saving is invalid causing a crash

    how to fix this ?
  2. Sykte macrumors regular

    Aug 26, 2010
    Without code/crash log, I doubt anyone will be able to help.
  3. jiminaus macrumors 65816


    Dec 16, 2010
    This is the correct user experience on iOS.

    This is the incorrect user experience on iOS.

    On iOS there should be no disconnect between the viewed/edited data and the saved data. An iOS user should not have the concept of saved verses unsaved state. If an iOS user changes a field, it's the data that the iOS user is changing, not just an in-memory copy of the data. So it's wrong to ask the user if s/he wants to save the data, because it should be the data itself that the user has just edited. This model is now even extending to the desktop with Mac OS X Lion.
  4. forum user macrumors regular

    Aug 28, 2008
    My 2c in addition to jiminaus:

    The "back" button should take the user back to the previous view using the data as entered.

    If an undo/confirm activity is required (for whatever reason :) ) I would suggest a Cancel and a Save button. "Cancel" to trigger the undo, "Save" to validate the new data and to close the view.

    - Olaf
  5. larswik macrumors 68000

    Sep 8, 2006
    I also had a question about this. When I hit the back button that is when I save the data to a plist in my Documents folder in my sandbox. If I wanted to pass data from my ViewController (say an image ) that is getting destroyed to the previous ViewController to use, when I hit the back button, do I do that through the plist? dp I save it to the plist and retrive it from the plist, or is there a way to pass that data to the previous ViewController object?
  6. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    You could store it with Singletons, call functions on your back to send it to the class that is above you in the navigation stack. .plists, SQLite (or CoreData).
    etc. there are many options.

Share This Page