您的位置:首页 > 移动开发 > Objective-C

Introduction to The Objective-C 2.0 Programming Language

2011-11-13 21:03 323 查看
转载请注明: http://www.cnblogs.com/cgblogs/articles/ObjC2_01.html

如有错误欢迎指正

An object-oriented approach to application development makes programs more intuitive to design, faster to develop, more amenable to modification, and easier to understand. Most object-oriented development environments consist of at least three parts:

• An object-oriented programming language and support library

• A library of objects

• A set of development tools

This document is about the first component of the development environment—the programming language and its runtime environment. It fully describes the Objective-C language, and provides a foundation for learning about the second component, the Mac OS X Objective-C application frameworks—collectively known as Cocoa. You can start to learn more about Cocoa by reading Getting Started with Cocoa. The two main development tools you use are Xcode and Interface Builder, described in Xcode User Guide and Interface Builder respectively.

——————

一种面向对象的应用程序开发方法,使程序直观,快速开发,易于修改,容易理解。大多数面向对象的开发环境至少有三个部分组成:

• 面向对象的编程语言和支持库

• 对象库

• 一组开发工具

本文档是关于开发环境的第一个部分----编程语言和运行时环境。它描述了Objective - C语言,提供了学习第二个组成部分的基础,Mac OS X的Objective - C的应用程序框架统称为Cocoa。您可以了解更多关于Cocoa在开始学习Cocoa之前。您使用的两个主要开发工具Xcode和Interface Builder,分别在Xcode用户指南和Interface Builder中描述。

——————

Important: This document describes version 2.0 of the Objective-C language which is released with Mac OS X v10.5. Several new features are introduced in this version, including properties (see “Properties” (page 45)), fast enumeration (see “Fast Enumeration” (page 71)), optional protocols, and (on modern platforms) non-fragile instance variables. These features are not available on versions of Mac OS X prior to 10.5. If you use these features, therefore, your application cannot run on versions of Mac OS X prior to 10.5. To learn about version 1.0 of the Objective-C language, read Object Oriented Programming and the Objective-C Programming Language 1.0.

——————

重要提示:本文档描述了2.0版本,跟随Mac OS X V10.5发布的Objective - C语言。在此版本中引入了一些新功能,包括属性(见“属性”(第45页)),快速枚举(见“快速枚举”(第71页)),任择议定书,并(在当前平台)非脆弱的实例变量。这些功能不可用在10.5之前的Mac OS X版本上。因此,如果你使用这些功能,您的应用程序无法运行在Mac OS X版本10.5之前。要了解Objective - C语言的版本1.0,阅读的面向对象编程和Objective - C编程语言1.0。

——————

The Objective-C language is a simple computer language designed to enable sophisticated object-oriented programming. Objective-C is defined as a small but powerful set of extensions to the standard ANSI C language. Its additions to C are mostly based on Smalltalk, one of the first object-oriented programming languages. Objective-C is designed to give C full object-oriented programming capabilities, and to do so in a simple and straightforward way.

——————

Objective - C语言是一种可以使用复杂的面向对象编程的简单计算机语言设计。 Objective - C是定义为小,但功能强大的标准ANSI C语言的扩展。其添加到C大多是基于Smalltalk,第一批面向对象的编程语言之一。 Objective - C是设计给C完整的面向对象编程能力,并做一个简单而直接的的方式。

——————

For those who have never used object-oriented programming to create applications before, this document is also designed to help you become familiar with object-oriented development. It spells out some of the implications of object-oriented design and gives you a flavor of what writing an object-oriented program is really like.

——————

对于那些从来没有使用过面向对象编程创建应用程序之前,本文件还旨在帮助您熟悉面向对象的开发。它阐明了一些面向对象的设计的影响,并让你写你喜欢的面向对象的程序的风格.

——————

Who Should Read This Document

——————

这份文档写给谁的

——————

The document is intended for readers who might be interested in:

▪ Learning about object-oriented programming

▪ Finding out about the basis for the Cocoa application framework

• Programming in Objective-C


This document both introduces the object-oriented model that Objective-C is based upon and fully documents the language. It concentrates on the Objective-C extensions to C, not on the C language itself. 
Because this isn’t a document about C, it assumes some prior acquaintance with that language. However, it doesn’t have to be an extensive acquaintance. Object-oriented programming in Objective-C is sufficiently different from procedural programming in ANSI C that you won’t be hampered if you’re not an experienced C programmer. 


——————

对该文档感兴趣的读者可能是:

• 学习面向对象编程

• 学习Cocoa应用程序框架基础

• Objective - C编程

这份文件既介绍了Objective - C语言面向对象模型的基础的和语言文档。它关注Objective – C对C的扩展,而不是C语言本身。因为这不是关于C文档,它假定大家熟悉C语言。但是对扩展不熟悉。面向对象语言Objective-C和ANSI C程序编程有很大的不同,如果你不是一个有经验的C程序员也不会受到阻碍。

——————

Organization of This Document 


——————

文档的组织

——————

This document is divided into several chapters and two appendixes. 


The following chapters describe the Objective-C language They cover all the features that the language adds to standard C and C++. These chapters present the language, but also touch on important elements of the runtime system.

——————

文档分为若干章节和两个附录。

下面的章节描述的Objective - C语言,涵盖所有添加到标准的C和C + +的功能。这些章节描述的语言,但也涉及到运行时系统的重要元素。

——————

▪ “Objects and Classes” (page 15)

▪ “Defining a Class” (page 31)

▪ “Properties” (page 45)

▪ “Protocols” (page 61)

▪ “Fast Enumeration” (page 71)

▪ “How Messaging Works” (page 75)

▪ “Enabling Static Behavior” (page 87)

▪ “Exception Handling” (page 91)

• “Threading” (page 95) 


The Apple compilers are based on the compilers of the GNU Compiler Collection. Objective-C syntax is a superset of GNU C/C++ syntax, and the Objective-C compiler works for C, C++ and Objective-C source code. The compiler recognizes Objective-C source files by the filename extension .m, just as it recognizes files containing only standard C syntax by filename extension .c. Similarly, the compiler recognizes C++ files that use Objective-C by the extension .mm. Other issues when using Objective-C with C++ are covered in “Using C++ With Objective-C” (page 97).

——————

苹果公司的编译器是基于GNU编译器集合的编译器。Objective - C的语法是GNU C / C + +语法的超集,和Objective - C的编译器对C,C + +和Objective - C源代码。 Objective - C源文件的编译器可以识别的文件扩展名.m,只是因为它承认文件包含文件扩展名的唯一标准的C语法.c.同样,编译器可以识别的C + +文件使用Objective - C的扩展.mm。其他问题时使用的目标 - C与C + +在覆盖“使用C + +使用Objective - C”(第97页)。

——————

“The Runtime System” (page 103) looks at the NSObject class and how Objective-C programs interact with the runtime system. In particular, it examines the paradigms for managing object allocations, dynamically loading new classes at runtime, and forwarding messages to other objects.

——————

“运行时系统”(第103页)介绍NSObject类以及Objective - C程序如何与交互运行时系统。特别是,它检查对象分配管理的模式,在运行时动态加载新的类,和发消息到其他对象。

——————

The appendixes contain reference material that might be useful for understanding the language. They are:

• “Language Summary” (page 127) lists and briefly comments on all of the Objective-C extensions to the C language.

• “Grammar” (page 135) presents, without comment, a formal grammar of the Objective-C extensions to the C language. This reference manual is meant to be read as a companion to the reference manual for C presented in The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie, published by Prentice Hall.

——————

附录包含可能理解的语言有用的参考材料。它们是:

• “语言摘要”(第127页)在所有的Objective - C的C语言扩展的名单和简要评论。

• “语法”(第135页)介绍,不加评论,一个正式的Objective - C的C语言的扩展语法。本参考手册是要读一个同伴布赖恩W. Kernighan和丹尼斯M.里奇由Prentice Hall出版,在C编程语言为C的参考手册。


——————

Conventions


Where this document discusses functions, methods, and other programming elements, it makes special use of computer voice and italic fonts. Computer voice denotes words or characters that are to be taken literally (typed as they appear). Italic denotes words that represent something else or can be varied. For example, the syntax: 


@interface ClassName(CategoryName)

means that @interface and the two parentheses are required, but that you can choose the class name 
and category name. 
Where example code is shown, ellipsis points indicates the parts, often substantial parts, that have been omitted:

- (void)encodeWithCoder:(NSCoder *)coder
{
[super encodeWithCoder:coder];
...
}


The conventions used in the reference appendix are described in that appendix. 


——————

公约

本文件讨论函数、方法和其他编程元素,它使特殊的计算机语言和斜体字。电脑语音表示,应采取的字面(类型出现)的字或字符。斜体表示的话,代表别的东西,或者可以是多种多样的。例如,语法如下:

@ interface ClassName(类别名称)

@ interface和两个括号是必需的,但你可以选择的类的名称和类别的名称。

如示例代码所示,省略号点表示的部分,部分已被省略:

- (void)encodeWithCoder:(NSCoder *)coder
{
[super encodeWithCoder:coder];
...
}


该附录中介绍参考附录中使用的约定。

——————

See Also 


Object-Oriented Programming with Objective-C describes object-oriented programming and development from the perspective of an Objective-C developer. 
Objective-C 2.0 Runtime Reference describes the data structures and functions of the Objective-C runtime support library. Your programs can use these interfaces to interact with the Objective-C runtime system. For example, you can add classes or methods, or obtain a list of all class definitions for loaded classes. 
Garbage Collection Programming Guide describes the garbage collection system used by Objective-C. 


Objective-C Release Notes describes some of the changes in the Objective-C runtime in the latest release of Mac OS X.

——————

另请参见

使用Objective - C的面向对象编程从一个Objective - C开发的角度描述了面向对象编程和发展。

Objective - C的2.0运行时参考描述的数据结构和功能的Objective - C运行支持库。你的程序可以使用这些接口与Objective - C运行系统进行交互。例如,您可以添加类或方法,或获得一个加载的类的所有类定义列表。

垃圾回收编程指南“介绍了Objective - C中所使用的垃圾收集系统。

Objective - C的发行说明介绍了一些在Objective - C运行在Mac OS X的最新版本的变化

转载请注明: http://www.cnblogs.com/cgblogs/articles/ObjC2_01.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: