如果UIApplicationMain()永远不会返回,那么自动释放池何时被释放? [英] If the UIApplicationMain() never returns then when does the autorelease pool gets released?

查看:118
本文介绍了如果UIApplicationMain()永远不会返回,那么自动释放池何时被释放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

Apple的文档清楚地指明:

Apple's doc clearly specifies:


返回值:
即使指定了整数返回类型,此函数也不会返回。当用户通过按Home键终止iPhone应用程序时,应用程序会立即通过调用退出系统函数退出,参数为零。

Return Value: Even though an integer return type is specified, this function never returns. When users terminate an iPhone application by pressing the Home button, the application immediately exits by calling the exit system function with an argument of zero.

其次,在
int UIApplicationMain(
int argc,
char * argv [],
NSString * principalClassName,
NSString * delegateClassName
);

我们如何从UIApplication子类访问argv?

Secondly, in int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName ); how can we access the argv from our UIApplication subclass?

推荐答案

自动释放池不会被释放。相反,操作系统只是从内存中删除你的应用程序。

The autorelease pool doesn't get released. Instead, the OS simply removes your application from memory.

这篇关于如果UIApplicationMain()永远不会返回,那么自动释放池何时被释放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆