Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
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..
 

diyora

macrumors newbie
Original poster
Jul 21, 2008
25
0
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.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Hello,
I use,
[[UIApplication sharedApplication] terminate];
It execute but this give me warning:may not respond to'-terminate'

Thank you.

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.
 

islikebasketbal

macrumors newbie
Oct 1, 2008
2
0
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!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Or use the documented POSIX standard call exit(0);

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.