目录 About Objective-C Essentials Why are you reading this? Supported Platforms The History of Objective-C The C Programming LanguageThe Smalltalk programming LanguageC meets Smalltalk Objective-C and Apple Installing Xcode and Compiling Objective-C on Mac OS X Installing Xcode on Mac OS XStarting XcodeStarting a New ProjectWriting an Objective-C Application with Xcode Compiling Objective-C from the Command Line Installing and using GNUstep and Objective-C on Windows Downloading the GNUstep PackagesInstalling MinGW and GNUstep on WindowsRunning the GNUstep Shell Testing the Installation Installing and Using GNUstep and Objective-C on Linux Installing GNUstep on Ubuntu Compiling Objective-C Code Building and Installing GNUstep on Linux Installing gcc and Objective-C Support on LinuxPackage DependenciesObtaining the GNUstep Source CodeConfiguring the Build ProcessBuilding GNUstepTesting the Objective-C and GNUstep Installation Compiling Objective-C Code Objective-C 2.0 Data Types int Data Typechar Data TypeSpecial Characters/Escape Sequencesfloat Data Typedouble Data Typeid Data TypeBOOL Data TypeObjective-C Data Type Qualifierslonglong longshort signed / unsigned Working with Variables and Constants in Objective-C What is an Objective-C VariableWhat is an Objective-C Constant? Type Casting Objective-C Variables Objective-C Operators and Expressions What is an Expression?The Basic Assignment OperatorObjective-C Arithmetic OperatorsCompound Assignment OperatorsIncrement and Decrement OperatorsComparison OperatorsBoolean Logical OperatorsThe Ternary OperatorBitwise OperatorsBitwise ANDBitwise ORBitwise XORBitwise Left ShiftBitwise Right Shift Compound Bitwise Operators Objective-C 2.0 Operator Precedence An Example of Objective-C Operator PrecedenceObjective-C Operator Precedence and Associativity Overriding Operator Precedence Commenting Objective-C Code Why Comment your Code?Single Line Comments Multi-line Comments Objective-C Flow Control with if and else Using the if StatementUsing if ... else .. StatementsUsing if ... else if .. Statements Summary The Objective-C switch Statement Why Use a switch Statement?Using the switch Statement SyntaxA switch Statement ExampleExplaining the Example Combining case Statements Objective-C Looping - The for Statement Why Use Loops?Objective-C Loop Variable ScopeCreating an Infinite for LoopBreaking Out of a for LoopNested for LoopsBreaking from Nested LoopsContinuing for Loops Using for Loops with Multiple Variables Objective-C Looping with do and while Statements The Objective-C while LoopObjective-C do ... while loopsBreaking from Loops The continue Statement An Overview of Objective-C Object Oriented Programming What is an Object?What is a Class?Declaring an Objective-C Class ImplementationAdding Instance Variables to a ClassDefine Class MethodsDeclaring an Objective-C Class ImplementationDeclaring, Initializing and Releasing a Class InstanceCalling Methods and Accessing Instance DataCreating the Program SectionBringing it all Together Structuring Object-Oriented Objective-C Code Writing Objective-C Class Methods Instance and Class MethodsCreating a New Class MethodThe @interface SectionThe @implementation Section The main() Function Objective-C - Data Encapsulation, Synthesized Accessors and Dot Notation Data EncapsulationSynthesized Accessor MethodsDirect Access to Encapsulated DataObjective-C and Dot Notation Controlling Access to Instance Variables Objective-C Inheritance Inheritance, Classes and SubclassesAn Objective-C Inheritance ExampleExtending the Functionality of a Subclass Overriding Inherited Methods Pointers and Indirection in Objective-C How Variables are StoredAn Overview of IndirectionIndirection and Objects Indirection and Object Copying Objective-C Dynamic Binding and Typing with the id Type Static Typing vs Dynamic TypingDynamic Binding Polymorphism Objective-C Variable Scope and Storage Class Variable ScopeBlock ScopeFunction ScopeGlobal ScopeFile Scope Variable Storage Class An Overview of Objective-C Functions What is a Function?How to Declare an Objective-C FunctionCalling an Objective-C FunctionFunction PrototypesFunction Scope and the static Specifier Static Variables in Functions Objective-C Enumerators Why Use EnumeratorsDeclaring an EnumerationCreating and Using an Enumeration Enumerators and Variable Names An Overview of the Objective-C Foundation Framework The Foundation FrameworkIncluding the Foundation Headers Finding the Foundation Framework Documentation Working with String Objects in Objective-C Strings without NSStringDeclaring Constant String ObjectsCreating Mutable and Immutable String ObjectsGetting the Length of a StringCopying a StringSearching for a SubstringReplacing Parts of a StringString Search and ReplaceDeleting Sections of a StringExtracting a Subsection of a StringInserting Text into a StringAppending Text to the End of a StringComparing StringsChecking for String Prefixes and SuffixesConverting to Upper or Lower CaseConverting Strings to Numbers Converting a String Object to ASCII Understanding Objective-C Number Objects Creating and Initializing NSNumber ObjectsGetting the Value of a Number ObjectComparing Number Objects Getting the Number Object Value as a String Working with Objective-C Array Objects Mutable and Immutable ArraysCreating an Array ObjectFinding out the Number of Elements in an ArrayAccessing the Elements of an Array objectAccessing Array Elements using Fast EnumerationAdding Elements to an Array ObjectInserting Elements into an ArrayDeleting Elements from an Array Object Sorting Array Objects Objective-C Dictionary Objects What are Dictionary Objects?Creating Dictionary ObjectsInitializing and Adding Entries to a Dictionary ObjectGetting an Entry CountAccessing Dictionary Entries Removing Entries from a Dictionary Object Working with Directories in Objective-C The Objective-C NSFileManager, NSFileHandle and NSData ClassesUnderstanding Pathnames in Objective-CCreating an NSFileManager Instance ObjectIdentifying the Current Working DirectoryChanging to a Different DirectoryCreating a New DirectoryDeleting a DirectoryRenaming or Moving a DirectoryGetting a Directory File Listing Getting the Attributes of a File or Directory Working with Files in Objective-C Creating an NSFileManager InstanceChecking if a File ExistsComparing the Contents of Two FilesChecking if a File is Readable/Writable/Executable/DeletableMoving/Renaming a FileCopying a FileRemoving a FileCreating a Symbolic LinkReading and Writing Files with NSFileManagerWorking with Files using the NSFileHandle ClassCreating an NSFileHandle ObjectNSFileHandle File Offsets and SeekingReading Data from a FileWriting Data to a File Truncating a File Constructing and Manipulating Paths with NSPathUtilities The Anatomy of a PathFinding a Temporary DirectoryGetting the Current User's Home DirectoryGetting the Home Directory of a Specified UserExtracting the Filename from a PathExtracting the Filename ExtensionStandardizing a Path Extracting the Components of a Path Copying Objects in Objective-C Objects and PointersCopying an Object in Objective-C using the <NSCopying> Protocol<NSCopying> Protocol and copyWithZone Method Implementation Performing a Deep Copy Using Objective-C Preprocessor Directives The #define StatementCreating Macros with the #define StatementChanging the Objective-C Language with #defineUndefining a Definition with #undefConditional Compilation The #import Directive