Save application state

Discussion in 'iOS Programming' started by ilx.mac, Jul 30, 2009.

  1. ilx.mac macrumors member

    Joined:
    Mar 10, 2009
    #1
    Hi there,

    I need to handle interrupt from my application. But i am not aware of that. While googling I found that, I need to save the state in applicationwillresign and reload the state in didbecomeactive. but I am not sure how to do that. I havent seen any code samples. Can you help me on this by providing some tips & code samples.


    Thanks in advance!:)
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    How you do this will depend entirely on your model layer. You should save this out along with enough additional data to reset your view state to the same as when interrupted.

    The collection classes all supply writeToFile: methods (and similar read methods). Personally I'd be using that unless you have large amounts of binary data...
     
  3. ilx.mac thread starter macrumors member

    Joined:
    Mar 10, 2009
    #3
    Thanks for your quick reply.

    For example, I have 10 rows displaying phone number in a tableview. And my file name is contactview. In viewdidload of contact view i am parsing an xml data & displaying it in the table view.

    While a phone no is selected, I am making a call from my application.

    Now what are the things, I need to store in a file?
    Also how to use the willresignactive & becomeactive methods?
    Do I need to use notifications?
    If yes can you tell me how to set values for notifications?

    Since this is my first app, i am not aware of what to do. Can you help me on this please?


    Thanks again!:)
     

Share This Page