Cocoa:int main函数 [英] Cocoa: int main function

查看:235
本文介绍了Cocoa:int main函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,int main函数在Cocoa程序中扮演什么角色?几乎所有我一直在看的示例代码只有下面的代码在main.m:

I'm curious, what role does the int main function play in a Cocoa program? Virtually all of the sample code I've been looking at has only the following code in main.m:

#import <Cocoa/Cocoa.h>


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

    return NSApplicationMain(argc,  (const char **) argv);
}

这是什么,程序在哪里开始执行命令?看起来我的概念需要重新调整。

What exactly is this doing, and where does the program actually start stepping through commands? It seems my conceptions need readjustment.

推荐答案

由于Cocoa项目启动像任何其他操作系统的入口点是main 。然而,Cocoa Architecture被构造为实际上从NSApplicationMain开始处理你的程序,它负责从你的应用程序加载初始窗口,并启动用于处理GUI事件的Events循环。

Since a Cocoa project starts like any other, the entry point for the Operating system is main. However the Cocoa Architecture is constructed to actually start the processing of your program from NSApplicationMain, which is responsible for loading the initial window from your application and starting up the Events loop used to process GUI events.

Apple在 Cocoa基础指南:Mac OS X上的核心应用程序架构

这篇关于Cocoa:int main函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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