omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Effects of iPhone home button to app

    Pythonista
    3
    6
    4042
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • donnieh
      donnieh last edited by

      If I have some simple code that displays "hello world" in a label with a button push, we know that that text will remain there. Normally if you press the home button and then come back to the app the text should still be there. However, I am finding when running the app in Xcode that when I return the text is cleared. Basically the app runs from a fresh start when i return.

      Why does this do this and how do I fix it? I have written apps in Xcode using Objective-C and it automatically remembers the app state when I return.

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        The Xcode template checks if the script is still running when you press the home button – if it isn't, it basically calls exit(0). The intention is to make restarting a script easier and to save some memory. If you don't want that, you could put something like time.sleep(10**7) at the end of your script.

        1 Reply Last reply Reply Quote 1
        • Tizzy
          Tizzy last edited by

          Just an interesting side question - how expensive, cpu-wise, is a running script while it's "sleeping?"

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            @donnieh I have to correct myself. What I described above used to be the case, but I've changed it in the 1.6-based template that you're probably using.

            You can change the behavior of the home button there by editing the "Info.plist" file that you'll find in the project. Simply select "NO" for the "Application does not run in background" setting (or delete the entire row, which is equivalent). Depending on your Xcode settings, you may see "UIApplicationExitsOnSuspend" as the setting name.

            1 Reply Last reply Reply Quote 0
            • donnieh
              donnieh last edited by donnieh

              Great! Thank you! I have to say that almost anyone making an iPhone app with Pythonista would run into this and would desire a solution.

              1 Reply Last reply Reply Quote 0
              • donnieh
                donnieh last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors