【翻译】(objc-1)介绍
【翻译】(objc-1)介绍
?
see
https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/objectivec/Introduction/introObjectiveC.html
?
原文见
https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/objectivec/Introduction/introObjectiveC.html
?
--------------------------------------------
?
Introduction
?
介绍
?
--------------------------------------------
?
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语言(注:ANSI是American National Standards Institute,美国国家标准学会的缩写。ANSI C是C语言使用最广泛的一个版本)的一种小型但强大的扩展集合。它对C的附加大多数基于Smalltalk,第一个面向对象编程语言之一(注:维基上说它是第二个,第一个应该是Simula)。Objective-C被设计为赋予C完全面向对象编程能力,以及设计为用一种简单和直接的方式做到这一点。
?
Most object-oriented development environments consist of several parts:
?
大多数面向对象开发环境由几个部分组成:
?
* An object-oriented programming language
?
* 一个面向对象编程语言
?
* A library of objects
?
* 一个对象库
?
* A suite of development tools
?
* 一个开发工具套装
?
* A runtime environment
?
* 一个运行时环境
?
This document is about the first component of the development environment—the programming language. This document also provides a foundation for learning about the second component, the Objective-C application frameworks—collectively known as Cocoa. The runtime environment is described in a separate document, Objective-C Runtime Programming Guide.
?
本文档是关于开发环境的第一个组件——编程语言。本文档还提供一个学习第二组件的基础,Objective-C应用程序框架——总称为Cocoa。运行时环境在一个单独的文档中描述,Objective-C运行时编程指南。
?
--------------------------------------------
?
Who Should Read This Document
?
谁应该阅读本文档
?
The document is intended for readers who might be interested in:
?
该文档是打算给那些可能兴趣于以下内容的读者看:
?
* Programming in Objective-C
?
* 用Objective-C编程
?
* Finding out about the basis for the Cocoa application frameworks
?
* 认识Cocoa应用程序框架的基础
?
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.
?
本文既介绍Objective-C所基于的面向对象模型,还完全地文档化该语言。它专注于Objective-C对C的扩展,而非C语言本身。
?
Because this isn’t a document about C, it assumes some prior acquaintance with that language. Object-oriented programming in Objective-C is, however, sufficiently different from procedural programming in ANSI C that you won’t be hampered if you’re not an experienced C programmer.
?
因为这不是关于C的文档,它假设了那种语言的一些预备知识。然而,在Objective-C中面向对象编程和ANSI C中的过程式编程非常地不同,所以如果你不是一个有经验的C程序员你也不会被妨碍。
?
--------------------------------------------
?
Organization of This Document
?
本文档的组织结构
?
The following chapters cover all the features Objective-C adds to standard C.
?
以下章节涵盖Objective-C添加到标准C的所有特性。
?
* “Objects, Classes, and Messaging”
?
* “对象,类,和消息”
?
* “Defining a Class”
?
* “定义一个类”
?
* “Protocols”
?
* “协议”
?
* “Declared Properties”
?
* “被声明的属性”
?
* “Categories and Extensions”
?
* “分类和扩展”
?
* “Associative References”
?
* “关联引用”
?
* “Fast Enumeration”
?
* “快速枚举”
?
* “Enabling Static Behavior”
?
* “使能静态行为”
?
* “Selectors”
?
* “选择器”
?
* “Exception Handling”
?
* “异常处理”
?
* “Threading”
?
* “线程”
?
A glossary at the end of this document provides definitions of terms specific to Objective-C and object-oriented programming.
?
本文档最后的术语表提供特定于Objective-C和面向对象编程的术语定义。
?
--------------------------------------------
?
Conventions
?
约定
?
This document 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:
?
本文档特殊地利用计算机发音(注:指令)和斜体字体。计算机发音指示字面上的单词或字符(当它们出现时要被打出来)。斜体指示单词代表其它一些东西或者可能有所不同。例如,语法:
?
@interfaceClassName(CategoryName)
?
@interface 类名(分类名)
?
means that @interface and the two parentheses are required, but that you can choose the class name and category name.
?
意思是@interface和两个括号是必需的,但你可以选择类名和分类名。
?
Where example code is shown, ellipsis points indicates the parts, often substantial parts, that have been omitted:
?
在出现示例代码的地方,省略号指示已经被忽略的部分,通常是较长的部分:
?
--------------------------------------------
?
- (void)encodeWithCoder:(NSCoder *)coder
{
? ? [super encodeWithCoder:coder];
? ? ...
}
?
--------------------------------------------
?
--------------------------------------------
?
See Also
?
另见
?
If you have never used object-oriented programming to create applications, you should read Object-Oriented Programming with Objective-C. You should also consider reading it if you have used other object-oriented development environments such as C++ and Java because they have many expectations and conventions different from those of Objective-C. Object-Oriented Programming with Objective-C is designed to help you become familiar with object-oriented development from the perspective of an Objective-C developer. 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.
?
如果你还没有使用过面向对象编程来创建应用程序,那么你应该阅读《Objective-C面向对象编程》。你还应该考虑阅读它如果你曾经使用过其它面向对象开发环境诸如C++和Java,因为它们由很多不同于Objective-C的期望和约定。《Objective-C面向对象编程》被设计为帮助你从Objective-C开发者的角度来熟悉面向对象开发。它讲解一些面向对象设计的内涵并且带给你对编写一个面向对象程序实际上像什么的感觉。
?
The Runtime System
?
运行时系统
?
Objective-C Runtime Programming Guide describes aspects of the Objective-C runtime and how you can use it.
?
Objective-C运行时编程指南描述Objective-C运行时的各个方面以及你可以如何使用它。
?
Objective-C 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.
?
Objective-C运行时参考描述Objective-C运行时支持库的数据结构和函数。你的程序可以使用这些接口与Objective-C运行时系统交互。例如,你可以添加类或方法,或者获得被加载类的所有类定义的列表。
?
Memory Management
?
内存管理
?
Objective-C supports three mechanisms for memory management: automatic garbage collection and reference counting:
?
Objective-C支持内存管理,自动垃圾回收和引用计数,的三种机制:
?
* Automatic Reference Counting (ARC), where the compiler reasons about the lifetimes of objects.
?
* 自动引用计数(ARC),在这里编译器推测对象的生命周期。
?
* Manual Reference Counting (MRC, sometimes referred to as MRR for “manual retain/release”), where you are ultimately responsible for determining the lifetime of objects.
?
* 手动引用计数(MRC,有时被称为MRR,表示“手动保持/释放”),在这里你最终负责决定对象的生命周期。
?
Manual reference counting is described in Advanced Memory Management Programming Guide.
?
手动引用计数在高级内存管理编程指南中被描述。
?
* Garbage collection, where you pass responsibility for determining the lifetime of objects to an automatic “collector.”
?
* 垃圾回收,在这里你把决定对象生命周期的责任交给自动“回收器”。
?
Garbage collection is described in Garbage Collection Programming Guide. (Not available for iOS—you cannot access this document through the iOS Dev Center.)
?
垃圾回收在垃圾回收编程指南中被描述。(对于iOS来说它是不可用的——你无法通过iOS开发中心访问到这个文档。)
?
--------------------------------------------
?
(c) 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-10-12)
?
Apple公司版权所有。(最后更新:2011-10-12)
?
(本人翻译欠佳,请以官方文档为准。或者参考:
* 基于Objective-C的面向对象编程(官方中文文档)
http://www.apple.com.cn/developer/mac/library/documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/chapter_1_section_1.html
)