Cocoa Programming for Mac OS X 第一章(What Is It?)摘录

A Little History


Apple has made the source code to the Unix part of Mac OS X available under the name Darwin. A community of developers continues to work to improve Darwin. You can learn more about Darwin at http://macosforge.org/.


NeXT then wrote a window server for the operating system. A window server takes events from the user and forwards them to the applications. The application then sends drawing commands back to the window server to update what the user sees. One of the nifty things about the NeXT window server is that the drawing code that goes to the window server is the same drawing code that would be sent to the printer. Thus, a programmer has to write the drawing code only once, and it can then be used for display on the screen or printing. In the NeXTSTEP days, programmers were writing code that generated PostScript. With Mac OS X, programmers are writing code that uses the CoreGraphics framework (also known as Quartz). Quartz can composite those graphics onto the screen, send them to the printer, or generate PDF data. The Portable Document Format is an open standard created by the Adobe Corporation for vector graphics.


If you have used Unix machines before, you are probably familiar with the X window server. The window server for Mac OS X is completely different but fulfills the same function as the X window server: It gets events from the user, forwards them to the applications, and puts data from the applications onto the screen. At the moment, the X protocol has poor support for antialiased fonts and transparency. This is one of the reasons that the Mac OS X window server looks so much better than an X window server.


NeXTSTEP became Mac OS X. It is Unix underneath(下面的;底部的), and you can get all the standard Unix programs, such as the Apache Web server, on Mac OS X, which is more stable than Windows and Mac OS 9. The user interface is spectacular. You, the developer, are going to love Mac OS X because Cocoa will enable you to write full-featured applications in a radically more efficient and elegant manner.


Frameworks

framework is a collection of classes that are intended to be used together. In other words, the classes are compiled together into a reusable library of code. Any related resources are put into a directory with the library. The directory is renamed with the extension .framework. You can find the built-in frameworks for your machine in /System/Library/Frameworks.

Cocoa is made up of three frameworks:

  1. Foundation: Every object-oriented programming language needs the standard value, collection, and utility classes. Strings, dates, lists, threads, and timers are in the Foundation framework.

  2. AppKit: All things related to the user interface are in the AppKit framework. Windows, buttons, text fields, events, and drawing classes are in the AppKit. You will also see this framework called the ApplicationKit.

  3. Core Data: Core Data makes it easy to save your objects to a file and then reload them into memory. We say that Core Data is a persistence framework.

Numerous other frameworks handle such duties as encryption, QuickTime, and CD burning, but this book focuses on Foundation, AppKit, and Core Data because they are the most commonly used. Once you have mastered these, the other frameworks will be easier to understand.


Most of the time, Cocoa fulfills the promise: Common things are easy, and uncommon things are possible. If you find yourself writing many lines of code to do something rather ordinary, you are probably on the wrong track.


Common Mistakes

Having watched many, many people work through this material, I've seen the same mistakes made hundreds of times. I see two mistakes particularly often: capitalization mistakes and forgotten connections.

It is easy to miss some warnings the first time a file is compiled. Because Xcode does incremental compiles, you may not see those warnings again unless you clean and rebuild the project. If you are stuck, try cleaning and rebuilding.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值