Exiting program?

  • Hi all!
    I have a small app where I have got an Exit button. When user clicks
    the button the message exit(0) is sent and the app treminates. So far
    so good.
    In the app I use NSUserDefaults to save strings to DB.
    ...and here is my problem.
    If I delete a row in my view and exit my app with exit(0) this row
    appears again when app is started, but if I delete a row and than
    quits my program with the main (left)  menu "Quit myApp" the row
    disapears and does not show on restart, so how is Quit in main menu
    set up and what is the difference compared with exit(0)??

    Many thanks in advance!

    Marcus
  • > ...and here is my problem.
    > If I delete a row in my view and exit my app with exit(0) this row
    > appears again when app is started

    It appears again because your application did not gracefully exit.

    You're looking for the NSApplication method -[terminate:(id)] -- call
    it like this:

        [NSApp terminate:nil];

    That's the equivalent to what happens via the main menu.

    Stephen Deken
    <stephen.deken...>
  • You should call [NSApp terminate:self] instead of calling exit(0). I
    believe the argument to terminate: doesn't usually matter -- you can
    supply nil as well.

    On Oct 31, 2006, at 3:20 PM, Marcus Pedersén wrote:

    > Hi all!
    > I have a small app where I have got an Exit button. When user
    > clicks the button the message exit(0) is sent and the app
    > treminates. So far so good.
    > In the app I use NSUserDefaults to save strings to DB.
    > ...and here is my problem.
    > If I delete a row in my view and exit my app with exit(0) this row
    > appears again when app is started, but if I delete a row and than
    > quits my program with the main (left)  menu "Quit myApp" the row
    > disapears and does not show on restart, so how is Quit in main menu
    > set up and what is the difference compared with exit(0)??
    >
    > Many thanks in advance!
    >
    > Marcus
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<hankh...>
    >
    > This email sent to <hankh...>
    >

    Hank Heijink
    www.hankheijink.com
    <hankh...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today