Re: Exit an Application

2009-04-14 Thread Ken Thomases


On Apr 13, 2009, at 9:18 AM, Luca C. wrote:


2009/4/13 Luca Ciciriello 

I've created an application with a button "Exit" and I've connected  
it with

the method:

- (IBAction)exitApp:(id)sender
{
  // TODO
}

Now my question is: "Which call I have to do to quit my application  
instead

of // TODO?"
Is there a NSsomething to call?





[[NSApplication sharedApplication] terminate:self];


Also, in this simple case, the button can directly target the  
application object with the terminate: action.  That is, the above - 
exitApp: method is an action method.  So is -[NSApplication  
terminate:].  It is an action method for the very purpose of being  
connected to UI elements via the target-action mechanism.


Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-14 Thread Benjamin Dobson


On 13 Apr 2009, at 22:52:15, Uli Kusterer wrote:

or the slightly shorter and a thoretically a tad more dangerous  
similar call with NSApp in it are really the only option. (Well,  
theoretically you could send yourself a "quit" Apple Event, but  
that's only of academical interest...)


Why is it more dangerous to use NSApp?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread WT

On Apr 13, 2009, at 11:52 PM, Uli Kusterer wrote:


Well,

calling exit() is the best way to shoot yourself in the foot. That  
would exit the app immediately, without saving any unsaved  
documents, without writing any cached NSUserDefaults changes to the  
hard disk etc. Its effect in a regular Cocoa application is only  
slightly better than choosing "Force Quit" and shooting down the  
app. In short, don't do it.


[[NSApplication sharedApplication] terminate: nil];

or the slightly shorter and a thoretically a tad more dangerous  
similar call with NSApp in it are really the only option. (Well,  
theoretically you could send yourself a "quit" Apple Event, but  
that's only of academical interest...)


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


And for anyone curious about the same question in relation to the  
iPhone OS, two comments come to mind:


a) you're not supposed to quit your own application; the user is in  
charge and can hit the home button if he/she wants to quit your  
application


b) still, if you really want to programmatically quit your  
application, you can try the analogous


[[UIApplication sharedApplication] performSelector:  
@selector(terminate)];


It works, but the final animation that an application goes through  
when the application quits to the home screen (the zooming effect)  
does not happen, which might confuse the user into thinking that your  
application crashed.


Wagner
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread Uli Kusterer

On 13.04.2009, at 16:19, Filip van der Meeren wrote:

You could always call exit(); from C
or [NSApp terminate:XXX];



Well,

 calling exit() is the best way to shoot yourself in the foot. That  
would exit the app immediately, without saving any unsaved documents,  
without writing any cached NSUserDefaults changes to the hard disk  
etc. Its effect in a regular Cocoa application is only slightly better  
than choosing "Force Quit" and shooting down the app. In short, don't  
do it.


 [[NSApplication sharedApplication] terminate: nil];

or the slightly shorter and a thoretically a tad more dangerous  
similar call with NSApp in it are really the only option. (Well,  
theoretically you could send yourself a "quit" Apple Event, but that's  
only of academical interest...)


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread Luca Ciciriello
Thanks to everybody. You saved my life I'v released the application to  
my Boss just in time.


Bye.

Luca.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread Filip van der Meeren

You could always call exit(); from C
or [NSApp terminate:XXX];

Filip van der Meeren
fi...@code2develop.com
http://sourceforge.net/projects/xlinterpreter


On 13 Apr 2009, at 16:13, Luca Ciciriello wrote:


Hi All.
I Know this, may be, is the most stupid question on this list by I'm  
pretty new using cocoa (I'm a C++ developer).
I've created an application with a button "Exit" and I've connected  
it with the method:


- (IBAction)exitApp:(id)sender
{
// TODO
}

Now my question is: "Which call I have to do to quit my application  
instead of // TODO?"

Is there a NSsomething to call?

Thanks in advance for any help.

Luca.

P.S.
I know you can answer me to read some manual before post these  
questions, but I've to release this app to my boss in less than an  
hour. Sorry.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/filip%40code2develop.com

This email sent to fi...@code2develop.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread Filip van der Meeren

You could always call exit(); from C
or [NSApp terminate:XXX];

Filip van der Meeren
fi...@code2develop.com
http://sourceforge.net/projects/xlinterpreter

On 13 Apr 2009, at 16:13, Luca Ciciriello wrote:


Hi All.
I Know this, may be, is the most stupid question on this list by I'm  
pretty new using cocoa (I'm a C++ developer).
I've created an application with a button "Exit" and I've connected  
it with the method:


- (IBAction)exitApp:(id)sender
{
// TODO
}

Now my question is: "Which call I have to do to quit my application  
instead of // TODO?"

Is there a NSsomething to call?

Thanks in advance for any help.

Luca.

P.S.
I know you can answer me to read some manual before post these  
questions, but I've to release this app to my boss in less than an  
hour. Sorry.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/filip%40code2develop.com

This email sent to fi...@code2develop.com




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Exit an Application

2009-04-13 Thread Luca C.
[[NSApplication sharedApplication] terminate:self];
2009/4/13 Luca Ciciriello 

> Hi All.
> I Know this, may be, is the most stupid question on this list by I'm pretty
> new using cocoa (I'm a C++ developer).
> I've created an application with a button "Exit" and I've connected it with
> the method:
>
> - (IBAction)exitApp:(id)sender
> {
>// TODO
> }
>
> Now my question is: "Which call I have to do to quit my application instead
> of // TODO?"
> Is there a NSsomething to call?


-- 
--Luca C.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Exit an Application

2009-04-13 Thread Luca Ciciriello

Hi All.
I Know this, may be, is the most stupid question on this list by I'm  
pretty new using cocoa (I'm a C++ developer).
I've created an application with a button "Exit" and I've connected it  
with the method:


- (IBAction)exitApp:(id)sender
{
// TODO
}

Now my question is: "Which call I have to do to quit my application  
instead of // TODO?"

Is there a NSsomething to call?

Thanks in advance for any help.

Luca.

P.S.
I know you can answer me to read some manual before post these  
questions, but I've to release this app to my boss in less than an  
hour. Sorry.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com