how to close application using command

Discussion in 'iOS Programming' started by diyora, Sep 28, 2008.

  1. diyora macrumors newbie

    Joined:
    Jul 21, 2008
    #1
    Hello all,
    I am doing coding in cocoa touch.I want to close my application using command(syntax).I am see different command close,stop but it is not working.

    thank you..
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Please learn to use the search. There is a way to do it in this thread. Note this uses an undocumented call: there is now official way in the SDK to do this...
     
  3. diyora thread starter macrumors newbie

    Joined:
    Jul 21, 2008
    #3
    how to close application using command

    Hello,
    I use,
    [[UIApplication sharedApplication] terminate];
    It execute but this give me warning:may not respond to'-terminate'

    Thank you.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    As I said: it's an undocumented call. Therefore it's not in the headers. This warning is what any reasonable programmer would expect.

    There is an obvious way to remove the warning via performSelector:. A good programmer would protect against the undocumented call changing by testing if the object responds to that selector before calling too...

    I expected that having been pointed in the correct direction you could solve minor issues on your own.
     
  5. islikebasketbal macrumors newbie

    Joined:
    Oct 1, 2008
    #5
    exit(0)

    Or use the documented POSIX standard call exit(0);

    BUT, all of these options look super ugly, so I would just let the user menu out. Like the iTunes Music Store does when you don't have WiFi!
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    That's not such a great idea as it will just kill your app dead right there. Using the call I mentioned above your app dies gracefully: all the normal app shutdown code gets called and the normal notifications get sent.
     

Share This Page