Proper way to exit iPhone application?

前端 未结 25 2734
难免孤独
难免孤独 2020-11-22 01:54

I am programming an iPhone app, and I need to force it to exit due to certain user actions. After cleaning up memory the app allocated, what\'s the appropriate method to ca

25条回答
  •  鱼传尺愫
    2020-11-22 02:48

    Hm, you may 'have to' quit the application if, say, your application requires an internet connection. You could display an alert and then do something like this:

    if ([[UIApplication sharedApplication] respondsToSelector:@selector(terminate)]) {
        [[UIApplication sharedApplication] performSelector:@selector(terminate)];
    } else {
        kill(getpid(), SIGINT); 
    }
    

提交回复
热议问题