Benches iPhone

2

How to use UIApp and NSApp for iphone app…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi! I am a newbie in iPhone apps development. Recently I was applying someone's engine to my application which has a line:

[NSApp terminate:self];

when I compile it, the error shows:

'NSApp undeclared'

I thought maybe it's because my application is for iphone, I changed it to:

[UIApp terminate:self];

but still the error says:

'UIApp undeclared'

Can anyone please let me know what's the problem? Thanks!

2 replies

Sign in or join Beachball Help to reply.

  1. 0

    RayNewbie

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi, and welcome to the Dev Forums!

    There isn't any UIApp in the iPhone UIKit, the application class is named UIApplication. However, while there was an undocumented terminate method in that class, I think it's been removed from the 3.0 SDK. The reason for this is that self-terminating apps violate the +iPhone Human Interface Guidelines+. The guidelines recommend putting up an alert message if an app can't continue. The user then terminates the app by pressing the Home button.

    If you're not seeking to place your app in the Store, you can terminate it by calling exit(0).

    Btw. there's no NSApp in the AppKit either. That application class is named NSApplication. Anyway, terminate is an instance method. There might be a define somewhere like:


    #define NSApp [NSapplication sharedApplication]

    - Ray

  2. 0

    peterpenn

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thank you Ray!