Cocoa Programming for Mac OS X 第二章(Let's Get Started)摘录

1.Instance variables that are pointers to other objects are called outlets. Methods that can be triggered by user interface objects are called actions.

2. this book, we discuss the following major types of projects:

  • Application: A program that creates windows.

  • Tool: A program that does not have a graphical user interface. Typically, a tool is a command line utility or a daemon that runs in the background.

  • Bundle or framework: A directory of resources that can be used in an application or a tool. A bundle (also called a plug-in) is dynamically loaded at runtime. An application typically links against a framework at compile time.

3.#import is similar to the C preprocessor's #include. However, #import ensures that the file is included only once. You are importing<Cocoa/Cocoa.h> because that includes the declaration of NSObject, which is the superclass of Foo.

Note that the declaration of the class starts with @interface. The @ symbol is not used in the C programming language. To minimize conflicts between C code and Objective-C code, Objective-C keywords are prefixed by @. Here are a few other Objective-C keywords: @end,@implementation@class@selector@protocol@propertyand @synthesize.

4.Let's briefly discuss the chronology(年表) of an application: When the process is started, it runs the NSApplicationMain function, which creates an instance of NSApplication. The application object reads the main nib file and unarchives the objects inside. The objects are all sent the message awakeFromNib. Then the application object checks for events. The timeline for these events appears in Figure 2.26.

Figure 2.26. A Timeline

  


When it receives an event from the keyboard and mouse, the window server puts the event data into the event queue for the appropriate application, as shown in Figure 2.27. The application object reads the event data from its queue and forwards it to a user interface object (like a button), and your code gets triggered. If your code changes the data in a view, the view is redisplayed. Then the application object checks its event queue for another event. This process of checking for events and reacting to them constitutes the main event loop.

Figure 2.27. The Role of the Window Server


When the user chooses Quit from the menu, NSApp is sent the terminate: message. This ends the process, and all your objects are destroyed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值