Method to save application state just before quit

I am using the user preferences to save the state of my game so that when a user goes away and comes back, it comes back at the same place they left. However, I am saving to this every turn. Is there a better way of doing this. Putting it in the applicationWillTerminate method maybe? If so, I'm not quite sure how to accomplish it there. Can anyone give any advice on this?
Thanks.

I made it work by setting up the MainViewController as a class and a variable in the Application Delegate. Then once the MainViewController was established, I called a method I put into the Application Delegate to set that variable to "self" (meaning MainViewController instance). Finally, in the applicationWillTerminate method of the Application Delegate, I used that variable to call the save method in the MainViewController.
Perhaps this is difficult to follow without seeing the code, but does this sound overly complicated, or about right?
Thanks.

Similar Messages

  • Why, suddenly, does Firefox decline to save all open windows before quitting?

    One of the best aspects of Firefox is that you can close your browser and Firefox will--or used to--remember all open tabs. Now my only option is open, or close and lose all tabs. Why?

    I agree with mrpoizun. I liked everything about Firefox before 4.
    This automatic saving of sessions has one big flaw! When opening FF, it shows a blank screen (simply because my innitial preference is to start on blank). If I should change my mind or accidentaly close this, the blank is saved, or rather the previous session is deleted. The Restore option is disabled.
    I request that "Save & Quit" be restored!
    Hm. Wonder if there is anything in my browsing habbits that requires FF4? If not, then I'll just try to find an earlier installation file.

  • Can't Save Application State in Acrobat X Pro

    There once was a time that I could close Acrobat X Pro with various and sundry pdfs open and upon reopening the application, those selfsame documents would reappear. This is no longer the case, and I have no idea what has changed.
    I am using Acrobat X Version 10.1.10 on Mac OS X Lion 10.7.5 (11G63).
    I tried removing the folder com.adobe.Acrobat.Pro.savedState in an attempt to reset the closing behavior of the program, but that didn't help.
    Any ideas?

    Hi David,
    1. Please check the permission on com.adobe.Acrobat.Pro.savedState folder.
    2. Go to Acrobat -> Preferences -> General (Category) -> make sure that "Show Welcome Screen" option is checked.
    Regards,
    Anoop

  • I'm trying to share to Media Browser a 20 minute still slide show with music and text. I have tried several times to save at 1080 HD, but just before it's finished, a message box pops up saying "File already open with write permission."  What's this mean?

    I'm trying to finalize/share to Media Browser a 20 minute still slide show with music and text. I'd like to finalize it 1080 hd and have tried several times, but just before it's finished, a message box pops up saying it can't be done because "File already open with with write permission."  What does this mean?  All files are closed; this iMovie project is the only thing open.  Does it mean one of the song files from iTunes? And should I just settle for saving it as a "large" file, which is what I'm trying right now?
    Thanks,
    Jamie

    Hi
    Error -49 opWrErr  File already open with write permission
    Trash the preference files while application is NOT Running.
    from Karsten Schlüter
    Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
    This issue occours only on MacOs machines using 10.7x
    try switching-off the Local Mobile Backup
    in Terminal copy/paste
    sudo tmutil disablelocal
    Re-launch Mac
    See also this post
    https://discussions.apple.com/thread/4434104?tstart=0
    Yours Bengt W

  • Flex iPad Application : Run code before application enters background  Application Type: Flex Mobile Application Target Platform: iPad AIR Version: 4.0 Development Environment: Flash builder 4.6  I want to run some code just before iphone application goes

    Application Type: Flex Mobile Application
    Target Platform: iPad
    AIR Version: 4.0
    Development Environment: Flash builder 4.6
    I want to run some code just before iphone application goes into background. I need function similar to didEnterBackground
    of native xcode app
    (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegat e_Protocol/Reference/Reference.h
    tml#//apple_ref/occ/intfm/UIApplicationDelegate/applicationDidEnterBackground:)
    I tried using devactivated function of flash.display.STAGE.
    I used following addEventListener:
    STAGE = this.parent.stage;
    STAGE.addEventListener(Event.DEACTIVATE, onAppDeactivated);
    It worked for me but only when device is connected to development environment in debug mode. When I create my release build
    it is not working.
    So how can I make sure that my code runs before application goes into background.

    Even I am facing almost same issue
    Problem installing Adhoc version to iPhone and iPad - Development Environment Is - Adobe Flash CS6

  • Are there any ways to make sure FCPX saves the project before quitting?

    The other day when I was working on a project, Final Cut Pro did not save any changes I made for the last 3 hours. I lost all of my work. I understand that FCP is supposed to autosave  projects, but it didn't. Are there any ways to make sure that it saves before quitting? I am currently running the trial version 10.0.8, and I plan to upgrade to the full version, soon, provided there aren't too many bugs.

    It turns out it was a corrupted project. All other projects autosave before quitting, but that one always displays the same last modified time. I solved it by creating a brand new project.

  • Shortcuts made in firefox give following fault just before they open: "fault during command is sending to application"

    shortcuts made in firefox give following fault just before they open: "fault during command is sending to application"
    only the shortcuts i made with firefox not those a made with IE.
    FF is my default browser

    Try:
    *http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox

  • The share button disappeared from my Facebook add-on just before I upgraded to Firefox 5.0. I thought by upgrading and reinstalling the add-on it might come back, but it didn't. All other FB buttons are there, near as I can tell. Any ideas? I'm using XP3.

    The share button disappeared from my Facebook add-on just before I upgraded to Firefox 5.0. I thought that maybe by upgrading and reinstalling the add-on it might come back, but it didn't. All the other FB buttons are there, near as I can tell. Any ideas? I'm still using XP3.

    Hello,
    I had the same problem with finding this file.
    There's no such file in Mac OS X version of Skype. But there's a directory for your Skype user account in /Users/%current_user_name%/Library/Application Support/Skype/
    try:
    quitting Skype
    renaming old folder
    signing into the Skype

  • How do I call browser Save As dialog box before downloading pdf files?

    How do I call browser Save As dialog box before downloading pdf files?
    Here's my favorite scenario:
    1. User clicks button
    2. Save As dialog displays
    3. User chooses location
    4. A set of PDF files download to that location OR a single zip file downloads
    Background:
    I want to ensure the user sees that files are being downloaded. I'm delivering content to users who may not be Web savvy.
    Concern:
    1. User has no clue how to find downloaded files or that files have even downloaded.
    2. I'd like to deliver the set as zip files. Not sure if self-opening zip files still exist.
    FYI:
    I'm using jQuery UI buttons. Not sure if that factors into response.

    Just for clarity, I'm not forcing a download. The user will click a button.
    Click a button or click a link, either way you're technically executing a script to force a download.
    I'm assuming that's the php file resident on the server.
    Yes but that's only part of it.  Once the contact form executes, another script is called up which opens the browser's download dialogue.
    Is there a php script for simply calling the Open/Save dialog box?
    Yes. 
    <?php
    /* This short script forces a file download.
       For simplicity, it's intended to be used for a single file.
       You can use multiple copies of this file (with unique names)
       with different variable values to use it with multiple files.
       Use of this script has a side-effect of hiding the location of the
       file on your server.
    // full server path to file to be downloaded (including filename)
    $Path2File = "path/to-file-on-server.zip";
    // the filename
    $theFileName = "name-of-file.zip";
    //the work gets done here
    header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header ("Content-Type: application/octet-stream");
    header ("Content-Length: " . filesize($Path2File));
    header ("Content-Disposition: attachment; filename=$theFileName");
    readfile($Path2File);
    ?>
    Name this file zip2download.php.
    Add a link to your HTML page:
    <a href="zip2download.php">Download Zip</a>
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com/

  • Logout has timed out because the application Mail failed to quit.

    Hello world... (Mac world that is)
    The message says more "Logout has timed out because the application Mail failed to quit. To try again, quit Mail and choose Log Out from the Apple menu."
    I tried everything. Still does not let me shut down.
    Other programs will not shut down at this time, including Finder. I also know that the Time Machine icon has been spinning for over an hour. So I imagine we are in a loop of sorts.
    Unfortunately, I have had similar troubles before that I did not record. So I figure I start now and see if somebody out there can help me.
    Peace!
    Chopo

    I'm having the same problem (can't logout, shut down or restart), but the referenced solution doesn't seem to apply. I do not get a "Cannot connect to server" message, I just get a "Logout has timed out" message. It seemed to happen after an automatic software update that was supposed to involve a restart, but it hasn't been able to restart since.
    Can you please clarify, what is meant by "delete the AutoLaunchedApplicationDictionary, which is located under the root node" (with reference to file loginwindow.plist)?
    This is what the loginwindow.plist file looks like now:
    bplist00Ñ!AutoLaunchedApplicationDictionary¢ÒTPathTHide-/Library/Printers/hp/hpio/HPEventHandler.app/Ò _N/Library/Application Support/Hewlett-Packard/Software Update/HP Scheduler.app//27
    I was at the genius bar earlier, and they said I need to 'archive and install' in order to 'reset the OS'... but there's got to be a better answer than that, no? Perhaps this plist thing? I'm surprised that even powering off the imac doesn't reset anything... it just comes back the way it was. I'm supposed to bring the 25 inch imac in to the mac store for surgery (archive and install), but seeing several similar cases on this discussion forum, without archive and install identified as the clear solution, I'm in search of a second opinion... or any suggestion for how to simply make this work the way it was before? Is it 10.5.4 that is causing this? Should I go back to 10.5.3?
    Any suggestions are appreciated. Thank you.

  • How to perform validity checks just before form data is saved?

    hello all,
    i need to perform some checks on various fields just before data on a standard form is saved, and to eventually rollback the transaction.
    if the checks are succesful i have to perform some db operation in transaction with main data.
    solution ( if existent! )  has to be addin only -> no triggers / no procedures / no sbo_transaction thingies
    scenario:
    involved tables:
    OITM
    USERDEFINEDTABLE1
    USERDEFINEDTABLE2
    involved forms:
    Items - OITM - formtypeex = "150"
    logic:
    an user defined field U_UDFCHECKACTIVE has been added to OITM, a combo box has been added to items form containing values Y and N, bound to OITM.U_UDFCHECKACTIVE.
    when the user saves an item, if OITM.U_UDFCHECKACTIVE == Y we have to perform additional checks on USERDEFINEDTABLE1
    if the check result is true we have to save OITM current data and insert a record in USERDEFINEDTABLE2 containing itmgrp value (  )
    if the check result is false we have to block save operation
    if OITM.U_UDFCHECKACTIVE == N no check is performed and everything works normally
    we started hooking the form data event for oitm / form type 150:
    Application.SBO_Application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(FormDataEventHandler.SBO_Application_FormDataEvent);
    then we filtered the event
    switch (BusinessObjectInfo.FormTypeEx)
                        case "150":
                            if (BusinessObjectInfo.BeforeAction &&
                                (BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE ||
                                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD))
                                BL.Items_BusinessLogic.SBO_Application_FormDataEvent(ref BusinessObjectInfo, out BubbleEvent);
    in our business logic class i don't know how to correctly check the values just before they are saved to db
    for example i tried using oitm.browser :
    if (oitm.Browser.GetByKeys(BusinessObjectInfo.ObjectKey))
                            String value =  oitm.UserFields.Fields.Item("U_UDFCHECKACTIVE ").Value as String;
                             //perform checks
                                  //if ok insert records and bubbleevent = true
                                  //if ko rollback the bubbleevent = false
    //if checks are not to be performed then bubbleevent = true....
    but it's wrong, as it populates oitm object from db, and not from the form. i have old values stored in the object, values tha are to be overwritten with those present on form.
    i tried inspecting the form for data sources but i don't know how to navigate to the right one, i found only system generated objects with SYS_##, with no clue about the related dbfield
    i tried getting the values directly from the form, but in object BusinessObjectInfo i don't have anything that identifies univocally the form i'm editing.
    i mean if i have 2 item forms open, i don't know which one is the one i'm saving.
    i'm expecting to find somewhere a temporary oitm business object containing values that are to be saved, values that i can easily check.
    so i'm asking you how to find those values in order to perform my bl checks
    thank you in advance

    Hi Christian,
    The values that are about to be saved should be in the datasources:
    form.DataSources.DBDataSources.Item("OITM");
    form.DataSources.DBDataSources.Item("ITM1");
    The form variable should be form 150.
    Best regards,
    Pedro Magueija

  • When I launch preview, it opens all the previous pictures unless I have "closed" their window before quitting.

    Hey everyone,
    I was hoping someone could help me... it appears that in OSX 10.7 (Lion), whenever I open Preview to see an image, I noticed that the last image I had opened, also opened.  This happens CONSITENTLY.  I figured out that this little "bug" seems to occur whenever I haven't specificly closed (Ctrl + w) a picture before quitting (ctrl + q).  So, if I only quit Preview... the next time I launch it every picture that I haven't closed just pops right back up.
    This makes no sense to me.  If somebody quits Preview to stop viewing a picture, they are obviously intentionally finished looking at it.  I could understand wanting a browser to restore a session, but a session of Preview?  Silly!
    My question... is there a preferance or anything that I can turn off so that when I quit, it doesn't relaunch those pics?  I looked around and couldn't find anything... so any help would be appreciated.
    Thanks all,

    That's not just Preview, ie also Safari is doing the same.
    From here:
    Now apps you close will reopen right where you left off, so you never have to start from scratch again. And when you install software updates, you no longer need to save your work, close your apps, and spend valuable time setting everything up again. With Resume, you can restart your Mac and return to what you were doing — with all your apps in the places where you left them.
    It's not a bug, it's a feature
    You can change it in for the whole system:
    System Preferences > General > "Restore windows when quitting and re-opening apps"

  • Error code: Application "widget name" DashboardClient quit unexpectedly

    After installing my cloned backup onto my iBook I find my dashboard is not loading most of it's widgets but gives me error messages of:
    "Application "Widget name"DashboardClient quit unexpectedly".
    The cloned backup does likewise.
    My Calculator and Calender widgets load normally !?!
    I've tried downloading and reinstalling several of the offending widgets w/o solving the problem.
    Oddly, a newly installed iStat Pro widget works !
    Any answers, Ye Geniuses !!!
    -Regards James V.

    It may have been some pre-existing corruption on the volume or introduced during the cloning. Create a new account, name it "test" and see how your widgets work in that User acct? (That will tell if your problem is systemwide or limited to your User acct.) This account is just for test, do nothing further with it.
    Open System Preferences >> Accounts >> "+" make it an admin account.
    If the widgets do not load in a fresh account you may be able to repair this with the 10.4.2 Stand Alone Combo Update. If that is what you are running.
    This is a fuller install, as opposed to an incremental "delta" update so it should overwrite any files that are damaged or missing. It does not matter if you have applied it before. It has worked well for many.
    Remember to Verify Disk before update and repair permissions after update from /Applications/Utilities/Disk Utility.
    BTW - are you still running 10.4.2 as your profile indicates and if so, why haven't you updated?
    If the widgets do work in a fresh user go a little further with your user:
    Navigate to these locations and trash the files in green. Then log out and back in, or restart.
    ~/Library/Caches/dashboardclient
    ~(yourhome)/Library/Preferences/com.apple.dashboard.plist
    ~(yourhome)/Library/Preferences/com.apple.dashboard.client.plist
    -mj
    [email protected]
    Message was edited by: macjack

  • Applications run slowly and quit when printing on a G5

    I recently migrated applications, documents, and accounts from a G4 to a G5., both running OS X Tiger 10.4.9. Since migrating, many times a day there have been problems with it.
    Applications (mostly FileMaker and Microsoft Word 2004) run a little more slowly than they should. Of more concern is how these applications will unexpectedly quit when printing. They will quit just before the print dialogue box is supposed to appear. It doesn't happen every time, but it shouldn't be happening at all. The printers used are all shared printers but not postscript-based printers.
    I've tried a number of things (deleting the printers and adding them again, repaired permissions, updated software, deleted corrupt fonts, uninstalled MS Office & reinstalled, zapped PRAM) and nothing has helped.
    I thought I'd ask here for any suggestions (since this looks like it might be a common enough problem) before I resort to reinstalling everything! Thanks!

    Reinstall if deleting .plist files doesn't help. Seems that crashing on launch is common enough after the recent update http://www.macfixit.com
    Backup. And whenever you do a clean install, back that up there and then, sparseimage works fine, and keep it handy if you need to restore.
    I'd run First Aid and Disk Warrior.
    I thought my printing problems began with the Security Update 2007-004 and went back to earlier image. Have not yet reapplied to test whether it would or not.
    After spending a couple full morning trying various fixes, a restore or reinstall did the trick. I'd suggest the same.

  • How to access application state from stateless web service?

    I have a beginner J2EE question. After reading through J2EE tutorial, I still don't know how to create an application that would run on J2EE server, and which would have a web service interface to other world, and which would have several threads running, which would connect to other enterprise applications via TCP? Because if I understand it correctly, web service requires a stateless session bean, which means that it can't access any stateleful session bean (except always create one and remove it instantly). So there seems to be no way to store application state and have running threads.
    I'm asking this because .NET seems to have a very simple Application dictionary, which can save all application objects, including threads, and it is very easy to access this Application state from a stateless web service. Isn't there any similar functionality in J2EE? And if not, how it should be done in Java world then?
    I guess that the Connector architecture could be the solution, but it is not documented in the tutorial.

    There's nothing in the J2EE spec that says that you have to use Web Services. Web Services by definition are stateless.
    If your requirements are that you have to use a session bean along with a Web Service, then the architecture needs to be rethought, because it doesn't seem to me that Web Services are what you want.
    That said, you can use a hybrid. You can expose some of the functionality of your application as Web Services while the remaining is implemented in a classic J2EE type framework that is stateful.
    I would also think that you could store your application state via entity beans. You could save and load them when the web service is accessed. An entity bean doesn't require a database... just some form of persistence (could be an XML file for instance).
    You need to decide which components of J2EE make sense when and where.

Maybe you are looking for

  • MAC to HGTV OUTPUTTING SUGGESTIONS

    Hi I used to stream online movies from my Power mac to my HGTV via the DVI to Video Apple adapter. Just upgraded to the new Mac Pro with the NVIDIA 8800gt card and realized the adapter is no longer supported (it only works with a couple of ATI cards)

  • Cross company code Purchase Rebate

    Hi All, I want create a purchase Rebate for cross company code please let me is it possible if so what are the configuration I need to make. Thanks & Regards Chand

  • Initializing a varying array of records?

    Hi everybody, Given below is a sample code. I have created a varying array of records. However I am unable to initialize the same. Can anybody help me out? DECLARE TYPE XRECORD IS RECORD(x NUMBER, y VARCHAR2(12)); TYPE VARRAYTYPE IS VARYING ARRAY(10)

  • Nokia N8 camera settings is not saved

    Hey. I found out that all the camera settings is not saved. For exampel i always want the grid displayed but then i have to turn it on manuelly every time. Same goes for the timer, id like it to be on 2sec so the picture not is taken as you push the

  • Deployed the EAR Application, but unable to access the Application's JSP's

    I installed SAP Netweaver 2004s and tried to create a Web application and an ear file. I followed all the steps. The deployment from the Developer Studio showed success. When I try to access the application using the url http://server:port/WebModuleP