目录 About Objective-C Essentials Why are you reading this?Supported Platforms The History of Objective-C The C Programming LanguageThe Smalltalk programming LanguageC meets SmalltalkObjective-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 XcodeCompiling 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 ShellTesting the Installation Installing and Using GNUstep and Objective-C on Linux Installing GNUstep on UbuntuCompiling 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 InstallationCompiling 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 longshortsigned / 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 ShiftCompound Bitwise Operators Objective-C 2.0 Operator Precedence An Example of Objective-C Operator PrecedenceObjective-C Operator Precedence and AssociativityOverriding Operator Precedence Commenting Objective-C Code Why Comment your Code?Single Line CommentsMulti-line Comments Objective-C Flow Control with if and else Using the if StatementUsing if ... else .. StatementsUsing if ... else if .. StatementsSummary The Objective-C switch Statement Why Use a switch Statement?Using the switch Statement SyntaxA switch Statement ExampleExplaining the ExampleCombining 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 LoopsUsing for Loops with Multiple Variables Objective-C Looping with do and while Statements The Objective-C while LoopObjective-C do ... while loopsBreaking from LoopsThe 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 TogetherStructuring Object-Oriented Objective-C Code Writing Objective-C Class Methods Instance and Class MethodsCreating a New Class MethodThe @interface SectionThe @implementation SectionThe main() Function Objective-C - Data Encapsulation, Synthesized Accessors and Dot Notation Data EncapsulationSynthesized Accessor MethodsDirect Access to Encapsulated DataObjective-C and Dot NotationControlling Access to Instance Variables Objective-C Inheritance Inheritance, Classes and SubclassesAn Objective-C Inheritance ExampleExtending the Functionality of a SubclassOverriding Inherited Methods Pointers and Indirection in Objective-C How Variables are StoredAn Overview of IndirectionIndirection and ObjectsIndirection and Object Copying Objective-C Dynamic Binding and Typing with the id Type Static Typing vs Dynamic TypingDynamic BindingPolymorphism Objective-C Variable Scope and Storage Class Variable ScopeBlock ScopeFunction ScopeGlobal ScopeFile ScopeVariable 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 SpecifierStatic Variables in Functions Objective-C Enumerators Why Use EnumeratorsDeclaring an EnumerationCreating and Using an EnumerationEnumerators and Variable Names An Overview of the Objective-C Foundation Framework The Foundation FrameworkIncluding the Foundation HeadersFinding 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 NumbersConverting a String Object to ASCII Understanding Objective-C Number Objects Creating and Initializing NSNumber ObjectsGetting the Value of a Number ObjectComparing Number ObjectsGetting 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 ObjectSorting Array Objects Objective-C Dictionary Objects What are Dictionary Objects?Creating Dictionary ObjectsInitializing and Adding Entries to a Dictionary ObjectGetting an Entry CountAccessing Dictionary EntriesRemoving 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 ListingGetting 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 FileTruncating 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 PathExtracting 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 ImplementationPerforming 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 CompilationThe #import Directive