Restart app from killed state.

Discussion in 'iOS Programming' started by RookieAppler, Jan 16, 2013.

  1. RookieAppler macrumors member

    Joined:
    Mar 15, 2012
    #1
    Hello I have an iPhone app working. It is based on web services. So i need WiFi/Cell connection. So i install app and get the data from web service and save it to Core Data DB on my phone.Now I work with the app creating a record.Works fine. If i have wifi i save the record to my SQL server. If not i save it to my iPhone.
    Here is my problem: After saving a record, i minimize the app. Then i delete it from the tray (i.e click home button twice and i get a tray of recent apps and i delete my app from there).Then immediately it stops working and goes in to main.m file with the exception. This is all in Simulator. On the actual device it goes back to login screen eventhough i have my login credentials clearly saved in settings. I want to know what happens when i kill my app from the tray. I put breakpoints in my appdelegate file and it doesnt hit anything..goes directly to main.m and exception. Where should i tell the app when it is relaunched to safely check for login details without throwing me an exception.
    To summarize : How to properly transition from killed state to relaunched state without getting exception..
    If you need more information, please ask. Thanks..
     
  2. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #2
    This happens because the debugger is still connected when you force kill the app. Try running the app in the simulator without running it through the debugger. AKA just open the simulator from the xcode menu for open developer tools and click simulator this will open the simulator and let you run the app.
     
  3. RookieAppler thread starter macrumors member

    Joined:
    Mar 15, 2012
    #3
    @KoolStar. Thanks. I did like you said and now on simulator also it shows up as it does on the device. But that is not my main concern. Is there a place i can store global variables .. tell the app that eventhough it has been relaunched there are some values and i do not need internet connection. I want the app to perform without WiFi as well.
     
  4. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    Is there any reason NSUserDefaults wouldn't work?
     
  5. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #5
    The only reason this may not work for the OP is that they have custom object that maybe that have not conformed to NSCoding and Decoding, perhaps the objects are very large.

    I would recommend creating a settings entity in core data since the application is using core data why not just use it to store your settings as well.
     
  6. RookieAppler thread starter macrumors member

    Joined:
    Mar 15, 2012
    #6
    I solved it by including information within a settings bundle i created. I have a Root.plist that came with it. I saved my settings there.
     

Share This Page