2010年7月19日月曜日

UIApplicationMainは戻らない

iPhoneアプリを触ってみた。

Interface Builderが作ったサンプルで
UIApplicationMain()が戻りを返さない。

[サンプル]
int main(int argc, char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

どっかで落ちてるのかと思って調べてみた。
結論だけ残すとこうなった。

UIKit Function Reference
UIApplicationMain
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.

[和訳]
この関数は戻り値を返さない。
HOMEボタンとか押されて※終了すべきときはexit(0)で終わる。
..orz
※iPhone4の場合、HOMEボタンでは終了しない。

0 件のコメント:

コメントを投稿