+ Reply
Results 1 to 5 of 5

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: applicationWillSuspend (etc) methods?

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
Does anyone know exactly when applicationWillSuspend is called? Is this called when the home button is pressed? When is applicationSuspended called? Or any of the similar applicationWill commands... everything I've
...
  1. #1
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Default applicationWillSuspend (etc) methods?
    Does anyone know exactly when applicationWillSuspend is called? Is this called when the home button is pressed? When is applicationSuspended called? Or any of the similar applicationWill commands... everything I've seen on the web so far is very unclear.
    Thanks
    JLA

  2. #2
    Developer
    Join Date
    Oct 2007
    Posts
    46
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Why not print something in each method to find out:

    Code:
    #define FILE_LOG                "/var/root/log.txt"
    
    void LOG(const char *fmt, ...)
    {
        static FILE *fp     = NULL;
        va_list     ap;
    
        if(fp == NULL) {
            fp      = fopen(FILE_LOG, "a+");
            if(fp)
                fprintf(fp, "============================\n");
        }
        if(fp) {
            va_start(ap,fmt);
            vfprintf(fp,fmt,ap);
            fflush(fp);
            va_end(ap);
        }
    }
    
    ....
    
        LOG("in %s\n", __func__);

  3. #3
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Because I figured someone might know the answer...
    as for logging, don't you think it's easier to use NSLog with a redirected output?

  4. #4
    Developer
    Join Date
    Aug 2007
    Posts
    380
    Thanks
    0
    Thanked 145 Times in 83 Posts

    Because I figured someone might know the answer...
    as for logging, don't you think it's easier to use NSLog with a redirected output?
    No, not really. I don't think those methods get called when you don't launch from springboard. If you launch from SSH to see the NSLog output, you can no longer test your home button commands.

    I can tell you that applicationWillTerminate gets called everytime you hit the home button on a "normal" app. I am not sure about the will suspend. I use the applicationWillTerminate to clean up
    -BigBoss
    Please do not send me messages here as I never check them. If you need to contact me, send me an email. My contact info is easy to find from inside Cydia.

  5. #5
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Thanks...
    Perhaps the suspend is called for sleep button presses and incoming phone calls. Does the terminate command trigger the willTerminate method? I've noticed different behavior on one of my programs for calling terminate versus hitting the home button.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts