Objective-C 编程语言官网文档(一)-简介
聲明:本文檔僅為個人學習過程中順手翻譯之作,方便開發的同胞借鑒參考。如有覺得譯的不好不到位的地方,歡迎指正,將及時做出更正
盡量尊重原文檔,因為首次Objective-C,有些地方可能直譯了沒有注意該語言的專有詞,希望指正。如需轉載,請注明出處
我的編程環境:
IDE:XCODE4.3.1
OS: MAC OS X 10.7.4
文章來譯自:http://developer.apple.com/
簡介
Objective-C語言是一種簡單的基于當下先進的面向對象的一種計算機語言。它作為標準的ANSI C語言的擴展,輕量但很強大。相對C, Objective-C新加入的一些內容更多是基于Smalltalk語言,Smalltalk是面向對象編程語言的創始者之一。Obejctive-C被設計賦予C語言完整的面向對象編程的能力,并以一種簡單和直接的方式來實現。大多數面向對象的開發環境都包含下列幾部分:
- 面向對象的編程語言;
- 一系列的對象庫;
- 一套開發工具;
- 運行時環境;
本文檔是關于第一個部分的介紹,即編程語言。 本文檔還包含了一些有關學習第二部分的基礎知識--Objective-C應用框架--Cocoa,運行時環境的表述可以參考另外一個文檔Objective-C Runtime Programming Guide.
適合閱讀本文檔的人群:1.Objective-C的開發人員
2.想要了解Cocoa應用框架基礎的朋友
本文檔不僅介紹了Obejctive-C的面向對象模型以及語言本身。專注于講解相對C擴展的東西,而不是C本身。
因為文檔并不著墨于C語言本身,可能有人覺得需要具備C的知識背景呢。作為一個面向對象的語言,Objective-C是跟面向過程的C有著很大的區別,所以即便你不是一個有經驗的C語言開發者,也不會妨礙你學習Objective-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”?(線程)
其它:
如果你從來沒有使用過面向對象的語言進行過開發,那么你可以先閱讀下文檔Object-Oriented Programming with Objective-C. 同樣,如果你有過面向對象開發的經驗,例如,C++, JAVA等語言的開發經驗,你也可以看下上面提到的文檔, 因為他們雖然都是面向對象的,但很多內容可能不盡相同。這個文檔講述了面向對象開發的思想以及一些基于面向對象思想的實現。
運行時環境
Objective-C Runtime Programming Guide?這個文檔向我們講解了有關Objective-C的運行時環境,以及我們如何使用。
Objective-C Runtime Reference?這個文檔則向我們介紹了Objective-C說支持的數據結構以及函數。你的程序也許會用到里面的借口來與Objective-C運行時環境進行交互。
內存管理
Objective-C支持三種方式的內存管理:自動垃圾回收及引用統計
-
Automatic Reference Counting?(ARC), 自動引用統計,編譯器會推斷出所有對象的生命周期
-
Manual Reference Counting?(MRC), 手動引用統計,有時也叫MRR,即手動保持,釋放。用于你完全掌控并決定對象的生命周期。
詳情可以參考?Advanced Memory Management Programming Guide.
-
Garbage collection, 垃圾回收,將決定對象生命周期的責任傳遞給自動回收器
可以參考Garbage Collection Programming Guide. (但文檔不適用于iOS—IOS的你可以通過訪問IOS開發中心獲取該文檔.)
原文:(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2)
?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.
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 applicationframeworks—collectively known as?Cocoa. The runtime environment is described in a separate document,Objective-C Runtime Programming Guide.
Who Should Read This Document
The document is intended for readers who might be interested in:
-
Programming in Objective-C
-
Finding out about the basis for the Cocoa application frameworks
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. 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.
Organization of This Document
The following chapters cover all the features Objective-C adds to standard 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.
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)
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]; |
| ... |
| } |
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.
The Runtime System
Objective-C Runtime Programming Guide?describes aspects of the Objective-C runtime and how you can use it.
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.
Memory Management
Objective-C supports three mechanisms for memory management: automatic garbage collection and reference counting:
-
Automatic Reference Counting?(ARC), where the compiler reasons about the lifetimes of objects.
-
Manual Reference Counting?(MRC, sometimes referred to as MRR for “manual retain/release”), where you are ultimately responsible for determining the lifetime of objects.
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.)
總結
以上是生活随笔為你收集整理的Objective-C 编程语言官网文档(一)-简介的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 伦茨服务器显示IMP,浅谈伦茨变频器的常
- 下一篇: Clonezilla克隆还原系统