From 9547fd69fec01cf320c230da29ee2a0412678580 Mon Sep 17 00:00:00 2001 From: wuxing Date: Sat, 14 Jun 2014 15:49:19 +0800 Subject: [PATCH 1/4] modify --- CNAME | 0 README.md | 0 .../01Interacting with Objective-C APIs.md | 0 .../03Mix and Match/DAG_2x.png | Bin ...ift and Objective-C in the Same Project.md | 0 .../03Mix and Match/bridgingheader_2x.png | Bin change_cdn.py | 0 chapter1/01_swift.html | 0 chapter1/02_a_swift_tour.html | 0 chapter1/chapter1.html | 0 chapter2/01_The_Basics.html | 0 chapter2/02_Basic_Operators.html | 0 chapter2/03_Strings_and_Characters.html | 0 chapter2/04_Collection_Types.html | 0 chapter2/05_Control_Flow.html | 0 chapter2/06_Functions.html | 0 chapter2/07_Closures.html | 0 chapter2/08_Enumerations.html | 0 chapter2/09_Classes_and_Structures.html | 0 chapter2/10_Properties.html | 0 chapter2/11_Methods.html | 0 chapter2/12_Subscripts.html | 0 chapter2/13_Inheritance.html | 0 chapter2/14_Initialization.html | 0 chapter2/15_Deinitialization.html | 0 chapter2/16_Automatic_Reference_Counting.html | 0 chapter2/17_Optional_Chaining.html | 0 chapter2/18_Type_Casting.html | 0 chapter2/19_Nested_Types.html | 0 chapter2/20_Extensions.html | 0 chapter2/21_Protocols.html | 0 chapter2/22_Generics.html | 0 chapter2/23_Advanced_Operators.html | 0 chapter2/chapter2.html | 0 chapter3/01_About_the_Language_Reference.html | 0 chapter3/02_Lexical_Structure.html | 0 chapter3/03_Types.html | 0 chapter3/04_Expressions.html | 0 chapter3/05_Declarations.html | 0 chapter3/06_Attributes.html | 0 chapter3/07_Patterns.html | 0 .../08_Generic_Parameters_and_Arguments.html | 0 chapter3/09_Summary_of_the_Grammar.html | 0 chapter3/10_Statements.html | 0 chapter3/chapter3.html | 0 gitbook/app.js | 0 gitbook/fonts/anonymouspro/400.woff | Bin gitbook/fonts/anonymouspro/400i.woff | Bin gitbook/fonts/anonymouspro/700.woff | Bin gitbook/fonts/anonymouspro/700i.woff | Bin gitbook/fonts/ebgaramond/400.woff | Bin gitbook/fonts/ebgaramond/400i.woff | Bin gitbook/fonts/merriweather/250.woff | Bin gitbook/fonts/merriweather/250i.woff | Bin gitbook/fonts/merriweather/400.woff | Bin gitbook/fonts/merriweather/400i.woff | Bin gitbook/fonts/merriweather/700.woff | Bin gitbook/fonts/merriweather/700i.woff | Bin gitbook/fonts/merriweather/900.woff | Bin gitbook/fonts/merriweather/900i.woff | Bin gitbook/fonts/opensans/300.woff | Bin gitbook/fonts/opensans/300i.woff | Bin gitbook/fonts/opensans/400.woff | Bin gitbook/fonts/opensans/400i.woff | Bin gitbook/fonts/opensans/600.woff | Bin gitbook/fonts/opensans/600i.woff | Bin gitbook/fonts/opensans/700.woff | Bin gitbook/fonts/opensans/700i.woff | Bin .../plugins/gitbook-plugin-mathjax/plugin.js | 0 .../plugins/gitbook-plugin-mixpanel/plugin.js | 0 googleb0a4f5a22e9cb82f.html | 0 index.html | 0 manifest.appcache | 0 search_index.json | 0 source/.DS_Store | Bin 0 -> 15364 bytes source/README.md | 0 source/SUMMARY.md | 0 source/chapter1/01_swift.md | 6 +- source/chapter1/02_a_swift_tour.md | 8 +- source/chapter1/chapter1.md | 0 source/chapter2/01_The_Basics.md | 92 +++++++++--------- source/chapter2/02_Basic_Operators.md | 0 source/chapter2/03_Strings_and_Characters.md | 0 source/chapter2/04_Collection_Types.md | 38 ++++---- source/chapter2/05_Control_Flow.md | 2 +- source/chapter2/06_Functions.md | 0 source/chapter2/07_Closures.md | 0 source/chapter2/08_Enumerations.md | 0 source/chapter2/09_Classes_and_Structures.md | 0 source/chapter2/10_Properties.md | 0 source/chapter2/11_Methods.md | 0 source/chapter2/12_Subscripts.md | 0 source/chapter2/13_Inheritance.md | 0 source/chapter2/14_Initialization.md | 0 source/chapter2/15_Deinitialization.md | 0 .../16_Automatic_Reference_Counting.md | 0 source/chapter2/17_Optional_Chaining.md | 0 source/chapter2/18_Type_Casting.md | 0 source/chapter2/19_Nested_Types.md | 0 source/chapter2/20_Extensions.md | 0 source/chapter2/21_Protocols.md | 0 source/chapter2/22_Generics.md | 0 source/chapter2/23_Advanced_Operators.md | 0 source/chapter2/chapter2.md | 0 .../01_About_the_Language_Reference.md | 0 source/chapter3/02_Lexical_Structure.md | 0 source/chapter3/03_Types.md | 0 source/chapter3/04_Expressions.md | 0 source/chapter3/05_Declarations.md | 0 source/chapter3/06_Attributes.md | 0 source/chapter3/07_Patterns.md | 0 .../08_Generic_Parameters_and_Arguments.md | 0 source/chapter3/09_Summary_of_the_Grammar.md | 0 source/chapter3/10_Statements.md | 0 source/chapter3/chapter3.md | 0 115 files changed, 73 insertions(+), 73 deletions(-) mode change 100644 => 100755 CNAME mode change 100644 => 100755 README.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png mode change 100644 => 100755 change_cdn.py mode change 100644 => 100755 chapter1/01_swift.html mode change 100644 => 100755 chapter1/02_a_swift_tour.html mode change 100644 => 100755 chapter1/chapter1.html mode change 100644 => 100755 chapter2/01_The_Basics.html mode change 100644 => 100755 chapter2/02_Basic_Operators.html mode change 100644 => 100755 chapter2/03_Strings_and_Characters.html mode change 100644 => 100755 chapter2/04_Collection_Types.html mode change 100644 => 100755 chapter2/05_Control_Flow.html mode change 100644 => 100755 chapter2/06_Functions.html mode change 100644 => 100755 chapter2/07_Closures.html mode change 100644 => 100755 chapter2/08_Enumerations.html mode change 100644 => 100755 chapter2/09_Classes_and_Structures.html mode change 100644 => 100755 chapter2/10_Properties.html mode change 100644 => 100755 chapter2/11_Methods.html mode change 100644 => 100755 chapter2/12_Subscripts.html mode change 100644 => 100755 chapter2/13_Inheritance.html mode change 100644 => 100755 chapter2/14_Initialization.html mode change 100644 => 100755 chapter2/15_Deinitialization.html mode change 100644 => 100755 chapter2/16_Automatic_Reference_Counting.html mode change 100644 => 100755 chapter2/17_Optional_Chaining.html mode change 100644 => 100755 chapter2/18_Type_Casting.html mode change 100644 => 100755 chapter2/19_Nested_Types.html mode change 100644 => 100755 chapter2/20_Extensions.html mode change 100644 => 100755 chapter2/21_Protocols.html mode change 100644 => 100755 chapter2/22_Generics.html mode change 100644 => 100755 chapter2/23_Advanced_Operators.html mode change 100644 => 100755 chapter2/chapter2.html mode change 100644 => 100755 chapter3/01_About_the_Language_Reference.html mode change 100644 => 100755 chapter3/02_Lexical_Structure.html mode change 100644 => 100755 chapter3/03_Types.html mode change 100644 => 100755 chapter3/04_Expressions.html mode change 100644 => 100755 chapter3/05_Declarations.html mode change 100644 => 100755 chapter3/06_Attributes.html mode change 100644 => 100755 chapter3/07_Patterns.html mode change 100644 => 100755 chapter3/08_Generic_Parameters_and_Arguments.html mode change 100644 => 100755 chapter3/09_Summary_of_the_Grammar.html mode change 100644 => 100755 chapter3/10_Statements.html mode change 100644 => 100755 chapter3/chapter3.html mode change 100644 => 100755 gitbook/app.js mode change 100644 => 100755 gitbook/fonts/anonymouspro/400.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/400i.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/700.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/700i.woff mode change 100644 => 100755 gitbook/fonts/ebgaramond/400.woff mode change 100644 => 100755 gitbook/fonts/ebgaramond/400i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/250.woff mode change 100644 => 100755 gitbook/fonts/merriweather/250i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/400.woff mode change 100644 => 100755 gitbook/fonts/merriweather/400i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/700.woff mode change 100644 => 100755 gitbook/fonts/merriweather/700i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/900.woff mode change 100644 => 100755 gitbook/fonts/merriweather/900i.woff mode change 100644 => 100755 gitbook/fonts/opensans/300.woff mode change 100644 => 100755 gitbook/fonts/opensans/300i.woff mode change 100644 => 100755 gitbook/fonts/opensans/400.woff mode change 100644 => 100755 gitbook/fonts/opensans/400i.woff mode change 100644 => 100755 gitbook/fonts/opensans/600.woff mode change 100644 => 100755 gitbook/fonts/opensans/600i.woff mode change 100644 => 100755 gitbook/fonts/opensans/700.woff mode change 100644 => 100755 gitbook/fonts/opensans/700i.woff mode change 100644 => 100755 gitbook/plugins/gitbook-plugin-mathjax/plugin.js mode change 100644 => 100755 gitbook/plugins/gitbook-plugin-mixpanel/plugin.js mode change 100644 => 100755 googleb0a4f5a22e9cb82f.html mode change 100644 => 100755 index.html mode change 100644 => 100755 manifest.appcache mode change 100644 => 100755 search_index.json create mode 100644 source/.DS_Store mode change 100644 => 100755 source/README.md mode change 100644 => 100755 source/SUMMARY.md mode change 100644 => 100755 source/chapter1/01_swift.md mode change 100644 => 100755 source/chapter1/02_a_swift_tour.md mode change 100644 => 100755 source/chapter1/chapter1.md mode change 100644 => 100755 source/chapter2/01_The_Basics.md mode change 100644 => 100755 source/chapter2/02_Basic_Operators.md mode change 100644 => 100755 source/chapter2/03_Strings_and_Characters.md mode change 100644 => 100755 source/chapter2/04_Collection_Types.md mode change 100644 => 100755 source/chapter2/05_Control_Flow.md mode change 100644 => 100755 source/chapter2/06_Functions.md mode change 100644 => 100755 source/chapter2/07_Closures.md mode change 100644 => 100755 source/chapter2/08_Enumerations.md mode change 100644 => 100755 source/chapter2/09_Classes_and_Structures.md mode change 100644 => 100755 source/chapter2/10_Properties.md mode change 100644 => 100755 source/chapter2/11_Methods.md mode change 100644 => 100755 source/chapter2/12_Subscripts.md mode change 100644 => 100755 source/chapter2/13_Inheritance.md mode change 100644 => 100755 source/chapter2/14_Initialization.md mode change 100644 => 100755 source/chapter2/15_Deinitialization.md mode change 100644 => 100755 source/chapter2/16_Automatic_Reference_Counting.md mode change 100644 => 100755 source/chapter2/17_Optional_Chaining.md mode change 100644 => 100755 source/chapter2/18_Type_Casting.md mode change 100644 => 100755 source/chapter2/19_Nested_Types.md mode change 100644 => 100755 source/chapter2/20_Extensions.md mode change 100644 => 100755 source/chapter2/21_Protocols.md mode change 100644 => 100755 source/chapter2/22_Generics.md mode change 100644 => 100755 source/chapter2/23_Advanced_Operators.md mode change 100644 => 100755 source/chapter2/chapter2.md mode change 100644 => 100755 source/chapter3/01_About_the_Language_Reference.md mode change 100644 => 100755 source/chapter3/02_Lexical_Structure.md mode change 100644 => 100755 source/chapter3/03_Types.md mode change 100644 => 100755 source/chapter3/04_Expressions.md mode change 100644 => 100755 source/chapter3/05_Declarations.md mode change 100644 => 100755 source/chapter3/06_Attributes.md mode change 100644 => 100755 source/chapter3/07_Patterns.md mode change 100644 => 100755 source/chapter3/08_Generic_Parameters_and_Arguments.md mode change 100644 => 100755 source/chapter3/09_Summary_of_the_Grammar.md mode change 100644 => 100755 source/chapter3/10_Statements.md mode change 100644 => 100755 source/chapter3/chapter3.md diff --git a/CNAME b/CNAME old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md b/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png old mode 100644 new mode 100755 diff --git a/change_cdn.py b/change_cdn.py old mode 100644 new mode 100755 diff --git a/chapter1/01_swift.html b/chapter1/01_swift.html old mode 100644 new mode 100755 diff --git a/chapter1/02_a_swift_tour.html b/chapter1/02_a_swift_tour.html old mode 100644 new mode 100755 diff --git a/chapter1/chapter1.html b/chapter1/chapter1.html old mode 100644 new mode 100755 diff --git a/chapter2/01_The_Basics.html b/chapter2/01_The_Basics.html old mode 100644 new mode 100755 diff --git a/chapter2/02_Basic_Operators.html b/chapter2/02_Basic_Operators.html old mode 100644 new mode 100755 diff --git a/chapter2/03_Strings_and_Characters.html b/chapter2/03_Strings_and_Characters.html old mode 100644 new mode 100755 diff --git a/chapter2/04_Collection_Types.html b/chapter2/04_Collection_Types.html old mode 100644 new mode 100755 diff --git a/chapter2/05_Control_Flow.html b/chapter2/05_Control_Flow.html old mode 100644 new mode 100755 diff --git a/chapter2/06_Functions.html b/chapter2/06_Functions.html old mode 100644 new mode 100755 diff --git a/chapter2/07_Closures.html b/chapter2/07_Closures.html old mode 100644 new mode 100755 diff --git a/chapter2/08_Enumerations.html b/chapter2/08_Enumerations.html old mode 100644 new mode 100755 diff --git a/chapter2/09_Classes_and_Structures.html b/chapter2/09_Classes_and_Structures.html old mode 100644 new mode 100755 diff --git a/chapter2/10_Properties.html b/chapter2/10_Properties.html old mode 100644 new mode 100755 diff --git a/chapter2/11_Methods.html b/chapter2/11_Methods.html old mode 100644 new mode 100755 diff --git a/chapter2/12_Subscripts.html b/chapter2/12_Subscripts.html old mode 100644 new mode 100755 diff --git a/chapter2/13_Inheritance.html b/chapter2/13_Inheritance.html old mode 100644 new mode 100755 diff --git a/chapter2/14_Initialization.html b/chapter2/14_Initialization.html old mode 100644 new mode 100755 diff --git a/chapter2/15_Deinitialization.html b/chapter2/15_Deinitialization.html old mode 100644 new mode 100755 diff --git a/chapter2/16_Automatic_Reference_Counting.html b/chapter2/16_Automatic_Reference_Counting.html old mode 100644 new mode 100755 diff --git a/chapter2/17_Optional_Chaining.html b/chapter2/17_Optional_Chaining.html old mode 100644 new mode 100755 diff --git a/chapter2/18_Type_Casting.html b/chapter2/18_Type_Casting.html old mode 100644 new mode 100755 diff --git a/chapter2/19_Nested_Types.html b/chapter2/19_Nested_Types.html old mode 100644 new mode 100755 diff --git a/chapter2/20_Extensions.html b/chapter2/20_Extensions.html old mode 100644 new mode 100755 diff --git a/chapter2/21_Protocols.html b/chapter2/21_Protocols.html old mode 100644 new mode 100755 diff --git a/chapter2/22_Generics.html b/chapter2/22_Generics.html old mode 100644 new mode 100755 diff --git a/chapter2/23_Advanced_Operators.html b/chapter2/23_Advanced_Operators.html old mode 100644 new mode 100755 diff --git a/chapter2/chapter2.html b/chapter2/chapter2.html old mode 100644 new mode 100755 diff --git a/chapter3/01_About_the_Language_Reference.html b/chapter3/01_About_the_Language_Reference.html old mode 100644 new mode 100755 diff --git a/chapter3/02_Lexical_Structure.html b/chapter3/02_Lexical_Structure.html old mode 100644 new mode 100755 diff --git a/chapter3/03_Types.html b/chapter3/03_Types.html old mode 100644 new mode 100755 diff --git a/chapter3/04_Expressions.html b/chapter3/04_Expressions.html old mode 100644 new mode 100755 diff --git a/chapter3/05_Declarations.html b/chapter3/05_Declarations.html old mode 100644 new mode 100755 diff --git a/chapter3/06_Attributes.html b/chapter3/06_Attributes.html old mode 100644 new mode 100755 diff --git a/chapter3/07_Patterns.html b/chapter3/07_Patterns.html old mode 100644 new mode 100755 diff --git a/chapter3/08_Generic_Parameters_and_Arguments.html b/chapter3/08_Generic_Parameters_and_Arguments.html old mode 100644 new mode 100755 diff --git a/chapter3/09_Summary_of_the_Grammar.html b/chapter3/09_Summary_of_the_Grammar.html old mode 100644 new mode 100755 diff --git a/chapter3/10_Statements.html b/chapter3/10_Statements.html old mode 100644 new mode 100755 diff --git a/chapter3/chapter3.html b/chapter3/chapter3.html old mode 100644 new mode 100755 diff --git a/gitbook/app.js b/gitbook/app.js old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/400.woff b/gitbook/fonts/anonymouspro/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/400i.woff b/gitbook/fonts/anonymouspro/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/700.woff b/gitbook/fonts/anonymouspro/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/700i.woff b/gitbook/fonts/anonymouspro/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/ebgaramond/400.woff b/gitbook/fonts/ebgaramond/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/ebgaramond/400i.woff b/gitbook/fonts/ebgaramond/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/250.woff b/gitbook/fonts/merriweather/250.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/250i.woff b/gitbook/fonts/merriweather/250i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/400.woff b/gitbook/fonts/merriweather/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/400i.woff b/gitbook/fonts/merriweather/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/700.woff b/gitbook/fonts/merriweather/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/700i.woff b/gitbook/fonts/merriweather/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/900.woff b/gitbook/fonts/merriweather/900.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/900i.woff b/gitbook/fonts/merriweather/900i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/300.woff b/gitbook/fonts/opensans/300.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/300i.woff b/gitbook/fonts/opensans/300i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/400.woff b/gitbook/fonts/opensans/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/400i.woff b/gitbook/fonts/opensans/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/600.woff b/gitbook/fonts/opensans/600.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/600i.woff b/gitbook/fonts/opensans/600i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/700.woff b/gitbook/fonts/opensans/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/700i.woff b/gitbook/fonts/opensans/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/plugins/gitbook-plugin-mathjax/plugin.js b/gitbook/plugins/gitbook-plugin-mathjax/plugin.js old mode 100644 new mode 100755 diff --git a/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js b/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js old mode 100644 new mode 100755 diff --git a/googleb0a4f5a22e9cb82f.html b/googleb0a4f5a22e9cb82f.html old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 diff --git a/manifest.appcache b/manifest.appcache old mode 100644 new mode 100755 diff --git a/search_index.json b/search_index.json old mode 100644 new mode 100755 diff --git a/source/.DS_Store b/source/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..85d5a50d25d7de28dab18861c9089eb46d95ff3c GIT binary patch literal 15364 zcmeI1O>7%Q6vy97(sq|kn{}JCb)mr`prpbn`4DjgrFEPys!%nmlQ>NRVeQ=}D>l2v zyS5`rqyQ3Xp&tT-kT@XG9uO3c;Q$B31uFFdQiUj}T)1&U0uJ1GGqX;L6Av&n}em$FaY(MDe_!etw>o#rPqNu8-YTFvLC)4v@ zIUN{5(N7tLX;vFGg86J%9`ihBwQOW3Y^yx0H}-pOVA!rz;K8d})YJ3G7MvG&fyQancGhdbi2M51?TNk6A5(bn!mBU$hH zQ>R~f^~~A#FNyJD_|1Sw)%ZW8x&l>$cl^?*7<`Sl(ctR`ng)kvb-n0Y$1KMP?2JA5cGj_u8-C7m zP1~ItFEe&i#L*4x6Sh@Q)kw{WG1pkIM3ffYqbmB!j7jfx#4}kRlecJEv{_N6nZLha zQ7+u7c3%qx7-K%YTlnDCHdWRAv1e%NM5r2XS5(~`cZ{s%gs#pma*bq4VgRADC!wej zj8Epgg#~&;U%0hL4=9R$`6>47Ck#J0nzvkf{J}%Xh!)lQE29)+TN|sQ9A^=IrfHci z$u=>+Ey)g1(AlaIg*Y69V=zS%?LryOz*#s4=izO*2$x_5K7}vfOSlYI;48QW-@*5A z9e#pe;8*w!5${3`>v0?IzCwVjrfk9|!RWPGANnaT-lrKo>oH z7MJlfzJ_n%yLbUF;z#%~ekR_krXt5-QLp6qIh8h&V?LB)We{)p(<0WvsyKgH)@K@Na%#?r=kz8&_9cE*Y4;ZP2JmEnf|qj7eW{(`B{rxPx_Xt zyf$d=uZP zlHKDK!3m4+Z6v!=y5KsVJ4bCyuGO;aVn@9H*CnD$E)jBxxOJ8YCP%qM$R*+?FA-f; zON3ZWWG)Fv0=EZ&TJf4OcK$#3*Z=?D9)po@DG5jd|B3+C4WtKB6k0i$sJ;t3Ymd?O zG+ivQe#^r05X$&*JXwAmPZf5q$d6;l7oNuOxFq>m{IalAqIA>$43PVO&RxKl`+riP z5F-4eBjP(^|Gy>xS&{@K0ZBj-kOU+FNk9^i1SA1TKoXDyBmqf45|9KWfjf=BAGdDq A=>Px# literal 0 HcmV?d00001 diff --git a/source/README.md b/source/README.md old mode 100644 new mode 100755 diff --git a/source/SUMMARY.md b/source/SUMMARY.md old mode 100644 new mode 100755 diff --git a/source/chapter1/01_swift.md b/source/chapter1/01_swift.md old mode 100644 new mode 100755 index 52d04681..ead740fe --- a/source/chapter1/01_swift.md +++ b/source/chapter1/01_swift.md @@ -5,9 +5,9 @@ # 关于 Swift ----------------- -Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用。Swift 结合了 C 和 Objective-C 的优点并且不受C兼容性的限制。Swift 采用安全的编程模式并添加了很多新特性,这将使编程更简单,更灵活,也更有趣。Swift 是基于成熟而且倍受喜爱的 Cocoa 和 Cocoa Touch 框架,他的降临将重新定义软件开发。 +Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用。Swift 结合了 C 和 Objective-C 的优点并且不受 C 兼容性的限制。Swift 采用安全的编程模式并添加了很多新特性,这将使编程更简单,更灵活,也更有趣。Swift 是基于成熟而且倍受喜爱的 Cocoa 和 Cocoa Touch 框架,他的降临将重新定义软件开发。 -Swift 的开发从很久之前就开始了。为了给 Swift 打好基础,苹果公司改进了编译器,调试器和框架结构。我们使用自动引用计数(Automatic Reference Counting, ARC)来简化内存管理。我们在 Foundation 和 Cocoa的基础上构建框架栈并将其标准化。Objective-C 本身支持块、集合语法和模块,所以框架可以轻松支持现代编程语言技术。正是得益于这些基础工作,我们现在才能发布这样一个用于未来苹果软件开发的新语言。 +Swift 的开发从很久之前就开始了。为了给 Swift 打好基础,苹果公司改进了编译器,调试器和框架结构。我们使用自动引用计数(Automatic Reference Counting, ARC)来简化内存管理。我们在 Foundation 和 Cocoa 的基础上构建框架栈并将其标准化。Objective-C 本身支持块、集合语法和模块,所以框架可以轻松支持现代编程语言技术。正是得益于这些基础工作,我们现在才能发布这样一个用于未来苹果软件开发的新语言。 Objective-C 开发者对 Swift 并不会感到陌生。它采用了 Objective-C 的命名参数以及动态对象模型,可以无缝对接到现有的 Cocoa 框架,并且可以兼容 Objective-C 代码。在此基础之上,Swift 还有许多新特性并且支持过程式编程和面向对象编程。 @@ -15,4 +15,4 @@ Swift 对于初学者来说也很友好。它是第一个既满足工业标准 Swift 将现代编程语言的精华和苹果工程师文化的智慧结合了起来。编译器对性能进行了优化,编程语言对开发进行了优化,两者互不干扰,鱼与熊掌兼得。Swift 既可以用于开发 “hello, world” 这样的小程序,也可以用于开发一套完整的操作系统。所有的这些特性让 Swift 对于开发者和苹果来说都是一项值得的投资。 -用 Swift 编写 iOS 和 OS X 应用将是一场美妙的体验,Swift 之后也会不断开发新特性和兼容性。我们对 Swift 充满信心,你还在等什么! +Swift 是编写 iOS 和 OS X 应用的极佳手段,并将伴随着新的特性和功能持续演进。我们对 Swift 充满信心,你还在等什么! diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md old mode 100644 new mode 100755 index ad40f81e..7fe1554a --- a/source/chapter1/02_a_swift_tour.md +++ b/source/chapter1/02_a_swift_tour.md @@ -32,7 +32,7 @@ ## 简单值 -使用`let`来声明常量,使用`var`来声明变量。一个常量的值在编译时并不需要获取,但是你只能为它赋值一次。也就是说你可以用常量来表示这样一个值:你只需要决定一次,但是需要使用很多次。 +使用`let`来声明常量,使用`var`来声明变量。一个常量的值,在编译的时候,并不需要有明确的值,但是你只能为它赋值一次。也就是说你可以用常量来表示这样一个值:你只需要决定一次,但是需要使用很多次。 ```swift var myVariable = 42 @@ -455,7 +455,7 @@ 2. 调用父类的构造器 3. 改变父类定义的属性值。其他的工作比如调用方法、getters和setters也可以在这个阶段完成。 -如果你不需要计算属性但是需要在设置一个新值之前运行一些代码,使用`willSet`和`didSet`。 +如果你不需要计算属性,但是仍然需要在设置一个新值之前或者之后运行代码,使用`willSet`和`didSet`。 比如,下面的类确保三角形的边长总是和正方形的边长相同。 @@ -665,7 +665,7 @@ 注意声明`SimpleStructure`时候`mutating`关键字用来标记一个会修改结构体的方法。`SimpleClass`的声明不需要标记任何方法因为类中的方法经常会修改类。 -使用`extension`来为现有的类型添加功能,比如添加一个计算属性的方法。你可以使用扩展来给任意类型添加协议,甚至是你从外部库或者框架中导入的类型。 +使用`extension`来为现有的类型添加功能,比如新的方法和参数。你可以使用扩展来改造定义在别处,甚至是从外部库或者框架引入的一个类型,使得这个类型遵循某个协议。 ```swift extension Int: ExampleProtocol { @@ -721,7 +721,7 @@ possibleInteger = .Some(100) ``` -在类型名后面使用`where`来指定一个需求列表——例如,要限定实现一个协议的类型,需要限定两个类型要相同,或者限定一个类必须有一个特定的父类。 +在类型名后面使用`where`来指定对类型的需求,比如,限定类型实现某一个协议,限定两个类型是相同的,或者限定某个类必须有一个特定的父类 ```swift func anyCommonElements (lhs: T, rhs: U) -> Bool { diff --git a/source/chapter1/chapter1.md b/source/chapter1/chapter1.md old mode 100644 new mode 100755 diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md old mode 100644 new mode 100755 index 6e5b0a98..dfbe0af0 --- a/source/chapter2/01_The_Basics.md +++ b/source/chapter2/01_The_Basics.md @@ -12,7 +12,7 @@ - [分号](#semicolons) - [整数](#integers) - [浮点数](#floating-point_numbers) -- [类型安全和类型推测](#type_safety_and_type_inference) +- [类型安全和类型推断](#type_safety_and_type_inference) - [数值型字面量](#numeric_literals) - [数值型类型转换](#numeric_type_conversion) - [类型别名](#type_aliases) @@ -195,7 +195,7 @@ Swift 也提供了一个特殊的无符号类型`UInt`,长度与当前平台 > 注意: > -尽量不要使用`UInt`,除非你真的需要存储一个和当前平台原生字长相同的无符号整数。除了这种情况,最好使用`Int`,即使你要存储的值已知是非负的。统一使用`Int`可以提高代码的可复用性,避免不同类型数字之间的转换,并且匹配数字的类型推测,请参考[类型安全和类型推测](#type_safety_and_type_inference)。 +尽量不要使用`UInt`,除非你真的需要存储一个和当前平台原生字长相同的无符号整数。除了这种情况,最好使用`Int`,即使你要存储的值已知是非负的。统一使用`Int`可以提高代码的可复用性,避免不同类型数字之间的转换,并且匹配数字的类型推断,请参考[类型安全和类型推断](#type_safety_and_type_inference)。 ## 浮点数 @@ -212,36 +212,36 @@ Swift 也提供了一个特殊的无符号类型`UInt`,长度与当前平台 `Double`精确度很高,至少有15位数字,而`Float`最少只有6位数字。选择哪个类型取决于你的代码需要处理的值的范围。 -## 类型安全和类型推测 +## 类型安全和类型推断 Swift 是一个_类型安全(type safe)_的语言。类型安全的语言可以让你清楚地知道代码要处理的值的类型。如果你的代码需要一个`String`,你绝对不可能不小心传进去一个`Int`。 由于 Swift 是类型安全的,所以它会在编译你的代码时进行_类型检查(type checks)_,并把不匹配的类型标记为错误。这可以让你在开发的时候尽早发现并修复错误。 -当你要处理不同类型的值时,类型检查可以帮你避免错误。然而,这并不是说你每次声明常量和变量的时候都需要显式指定类型。如果你没有显式指定类型,Swift 会使用_类型推测(type inference)_来选择合适的类型。有了类型推测,编译器可以在编译代码的时候自动推测出表达式的类型。原理很简单,只要检查你赋的值即可。 +当你要处理不同类型的值时,类型检查可以帮你避免错误。然而,这并不是说你每次声明常量和变量的时候都需要显式指定类型。如果你没有显式指定类型,Swift 会使用_类型推断(type inference)_来选择合适的类型。有了类型推断,编译器可以在编译代码的时候自动推断出表达式的类型。原理很简单,只要检查你赋的值即可。 -因为有类型推测,和 C 或者 Objective-C 比起来 Swift 很少需要声明类型。常量和变量虽然需要明确类型,但是大部分工作并不需要你自己来完成。 +因为有类型推断,和 C 或者 Objective-C 比起来 Swift 很少需要声明类型。常量和变量虽然需要明确类型,但是大部分工作并不需要你自己来完成。 -当你声明常量或者变量并赋初值的时候类型推测非常有用。当你在声明常量或者变量的时候赋给它们一个_字面量(literal value 或 literal)_即可触发类型推测。(字面量就是会直接出现在你代码中的值,比如`42`和`3.14159`。) +当你声明常量或者变量并赋初值的时候类型推断非常有用。当你在声明常量或者变量的时候赋给它们一个_字面量(literal value 或 literal)_即可触发类型推断。(字面量就是会直接出现在你代码中的值,比如`42`和`3.14159`。) -例如,如果你给一个新常量赋值`42`并且没有标明类型,Swift 可以推测出常量类型是`Int`,因为你给它赋的初始值看起来像一个整数: +例如,如果你给一个新常量赋值`42`并且没有标明类型,Swift 可以推断出常量类型是`Int`,因为你给它赋的初始值看起来像一个整数: let meaningOfLife = 42 - // meaningOfLife 会被推测为 Int 类型 + // meaningOfLife 会被推断为 Int 类型 -同理,如果你没有给浮点字面量标明类型,Swift 会推测你想要的是`Double`: +同理,如果你没有给浮点字面量标明类型,Swift 会推断你想要的是`Double`: let pi = 3.14159 - // pi 会被推测为 Double 类型 + // pi 会被推断为 Double 类型 -当推测浮点数的类型时,Swift 总是会选择`Double`而不是`Float`。 +当推断浮点数的类型时,Swift 总是会选择`Double`而不是`Float`。 -如果表达式中同时出现了整数和浮点数,会被推测为`Double`类型: +如果表达式中同时出现了整数和浮点数,会被推断为`Double`类型: let anotherPi = 3 + 0.14159 - // anotherPi 会被推测为 Double 类型 + // anotherPi 会被推断为 Double 类型 -原始值`3`没有显式声明类型,而表达式中出现了一个浮点字面量,所以表达式会被推测为`Double`类型。 +原始值`3`没有显式声明类型,而表达式中出现了一个浮点字面量,所以表达式会被推断为`Double`类型。 ## 数值型字面量 @@ -285,7 +285,7 @@ Swift 是一个_类型安全(type safe)_的语言。类型安全的语言可 ## 数值型类型转换 -通常来讲,即使代码中的整数常量和变量已知非负,也请使用`Int`类型。总是使用默认的整数类型可以保证你的整数常量和变量可以直接被复用并且可以匹配整数类字面量的类型推测。 +通常来讲,即使代码中的整数常量和变量已知非负,也请使用`Int`类型。总是使用默认的整数类型可以保证你的整数常量和变量可以直接被复用并且可以匹配整数类字面量的类型推断。 只有在必要的时候才使用其他整数类型,比如要处理外部的长度明确的数据或者为了优化性能、内存占用等等。使用显式指定长度的类型可以及时发现值溢出并且可以暗示正在处理特殊数据。 ### 整数转换 @@ -305,7 +305,7 @@ Swift 是一个_类型安全(type safe)_的语言。类型安全的语言可 let one: UInt8 = 1 let twoThousandAndOne = twoThousand + UInt16(one) -现在两个数字的类型都是`UInt16`,可以进行相加。目标常量`twoThousandAndOne`的类型被推测为`UInt16`,因为它是两个`UInt16`值的和。 +现在两个数字的类型都是`UInt16`,可以进行相加。目标常量`twoThousandAndOne`的类型被推断为`UInt16`,因为它是两个`UInt16`值的和。 `SomeType(ofInitialValue)`是调用 Swift 构造器并传入一个初始值的默认方法。在语言内部,`UInt16`有一个构造器,可以接受一个`UInt8`类型的值,所以这个构造器可以用现有的`UInt8`来创建一个新的`UInt16`。注意,你并不能传入任意类型的值,只能传入`UInt16`内部有对应构造器的值。不过你可以扩展现有的类型来让它可以接收其他类型的值(包括自定义类型),请参考[扩展](20_Extensions.html)。 @@ -316,20 +316,20 @@ Swift 是一个_类型安全(type safe)_的语言。类型安全的语言可 let three = 3 let pointOneFourOneFiveNine = 0.14159 let pi = Double(three) + pointOneFourOneFiveNine - // pi 等于 3.14159,所以被推测为 Double 类型 + // pi 等于 3.14159,所以被推断为 Double 类型 -这个例子中,常量`three`的值被用来创建一个`Double`类型的值,所以加号两边的数类型相同。如果不进行转换,两者无法相加。 +这个例子中,常量`three`的值被用来创建一个`Double`类型的值,所以加号两边的数类型须相同。如果不进行转换,两者无法相加。 浮点数到整数的反向转换同样行,整数类型可以用`Double`或者`Float`类型来初始化: let integerPi = Int(pi) - // integerPi 等于 3,所以被推测为 Int 类型 + // integerPi 等于 3,所以被推断为 Int 类型 当用这种方式来初始化一个新的整数值时,浮点值会被截断。也就是说`4.75`会变成`4`,`-3.9`会变成`-3`。 > 注意: > -结合数字类常量和变量不同于结合数字类字面量。字面量`3`可以直接和字面量`0.14159`相加,因为数字字面量本身没有明确的类型。它们的类型只在编译器需要求值的时候被推测。 +结合数字类常量和变量不同于结合数字类字面量。字面量`3`可以直接和字面量`0.14159`相加,因为数字字面量本身没有明确的类型。它们的类型只在编译器需要求值的时候被推断出来。 ## 类型别名 @@ -355,7 +355,7 @@ Swift 有一个基本的_布尔(Boolean)_类型,叫做`Bool`。布尔值 let orangesAreOrange = true let turnipsAreDelicious = false -`orangesAreOrange`和`turnipsAreDelicious`的类型会被推测为`Bool`,因为它们的初值是布尔字面量。就像之前提到的`Int`和`Double`一样,如果你创建变量的时候给它们赋值`true`或者`false`,那你不需要将常量或者变量声明为`Bool`类型。初始化常量或者变量的时候如果所赋的值类型已知,就可以触发类型推测,这让 Swift 代码更加简洁并且可读性更高。 +`orangesAreOrange`和`turnipsAreDelicious`的类型会被推断为`Bool`,因为它们的初值是布尔字面量。就像之前提到的`Int`和`Double`一样,如果你创建变量的时候给它们赋值`true`或者`false`,那你不需要将常量或者变量声明为`Bool`类型。初始化常量或者变量的时候如果所赋的值类型已知,就可以触发类型推断,这让 Swift 代码更加简洁并且可读性更高。 当你编写条件语句比如`if`语句的时候,布尔值非常有用: @@ -439,9 +439,9 @@ _元组(tuples)_把多个值组合成一个复合值。元组内的值可以 元组在临时组织值的时候很有用,但是并不适合创建复杂的数据结构。如果你的数据结构并不是临时使用,请使用类或者结构体而不是元组。请参考[类和结构体](09_Classes_and_Structures.html)。 -## 可选 +## 可选类型 -使用_可选(optionals)_来处理值可能缺失的情况。可选表示: +使用_可选类型(optionals)_来处理值可能缺失的情况。可选类型表示: * _有_值,等于 x @@ -451,7 +451,7 @@ _元组(tuples)_把多个值组合成一个复合值。元组内的值可以 > 注意: > -C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C 中的一个特性,一个方法要不返回一个对象要不返回`nil`,`nil`表示“缺少一个合法的对象”。然而,这只对对象起作用——对于结构体,基本的 C 类型或者枚举类型不起作用。对于这些类型,Objective-C 方法一般会返回一个特殊值(比如`NSNotFound`)来暗示值缺失。这种方法假设方法的调用者知道并记得对特殊值进行判断。然而,Swift 的可选可以让你暗示_任意类型_的值缺失,并不需要一个特殊值。 +C 和 Objective-C 中并没有可选类型这个概念。最接近的是 Objective-C 中的一个特性,一个方法要不返回一个对象要不返回`nil`,`nil`表示“缺少一个合法的对象”。然而,这只对对象起作用——对于结构体,基本的 C 类型或者枚举类型不起作用。对于这些类型,Objective-C 方法一般会返回一个特殊值(比如`NSNotFound`)来暗示值缺失。这种方法假设方法的调用者知道并记得对特殊值进行判断。然而,Swift 的可选类型可以让你暗示_任意类型_的值缺失,并不需要一个特殊值。 来看一个例子。Swift 的`String`类型有一个叫做`toInt`的方法,作用是将一个`String`值转换成一个`Int`值。然而,并不是所有的字符串都可以转换成一个整数。字符串`"123"`可以被转换成数字`123`,但是字符串`"hello, world"`不行。 @@ -459,15 +459,15 @@ C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C let possibleNumber = "123" let convertedNumber = possibleNumber.toInt() - // convertedNumber 被推测为类型 "Int?", 或者类型 "optional Int" + // convertedNumber 被推断为类型 "Int?", 或者类型 "optional Int" -因为`toInt`方法可能会失败,所以它返回一个_可选的(optional)_`Int`,而不是一个`Int`。一个可选的`Int`被写作`Int?`而不是`Int`。问号暗示包含的值是可选,也就是说可能包含`Int`值也可能不包含值。(不能包含其他任何值比如`Bool`值或者`String`值。只能是`Int`或者什么都没有。) +因为`toInt`方法可能会失败,所以它返回一个_可选类型(optional)_`Int`,而不是一个`Int`。一个可选的`Int`被写作`Int?`而不是`Int`。问号暗示包含的值是可选类型,也就是说可能包含`Int`值也可能不包含值。(不能包含其他任何值比如`Bool`值或者`String`值。只能是`Int`或者什么都没有。) ### if 语句以及强制解析 -你可以使用`if`语句来判断一个可选是否包含值。如果可选有值,结果是`true`;如果没有值,结果是`false`。 +你可以使用`if`语句来判断一个可选是否包含值。如果可选类型有值,结果是`true`;如果没有值,结果是`false`。 -当你确定可选_确实_包含值之后,你可以在可选的名字后面加一个感叹号(`!`)来获取值。这个惊叹号表示“我知道这个可选有值,请使用它。”这被称为可选值的_强制解析(forced unwrapping)_: +当你确定可选类型_确实_包含值之后,你可以在可选的名字后面加一个感叹号(`!`)来获取值。这个惊叹号表示“我知道这个可选有值,请使用它。”这被称为可选值的_强制解析(forced unwrapping)_: if convertedNumber { println("\(possibleNumber) has an integer value of \(convertedNumber!)") @@ -485,7 +485,7 @@ C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C ### 可选绑定 -使用_可选绑定(optional binding)_来判断可选是否包含值,如果包含就把值赋给一个临时常量或者变量。可选绑定可以用在`if`和`while`语句中来对可选的值进行判断并把值赋给一个常量或者变量。`if`和`while`语句,请参考[控制流](05_Control_Flow.html)。 +使用_可选绑定(optional binding)_来判断可选类型是否包含值,如果包含就把值赋给一个临时常量或者变量。可选绑定可以用在`if`和`while`语句中来对可选类型的值进行判断并把值赋给一个常量或者变量。`if`和`while`语句,请参考[控制流](05_Control_Flow.html)。 像下面这样在`if`语句中写一个可选绑定: @@ -506,9 +506,9 @@ C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C “如果`possibleNumber.toInt`返回的可选`Int`包含一个值,创建一个叫做`actualNumber`的新常量并将可选包含的值赋给它。” -如果转换成功,`actualNumber`常量可以在`if`语句的第一个分支中使用。它已经被可选_包含的_值初始化过,所以不需要再使用`!`后缀来获取它的值。在这个例子中,`actualNumber`只被用来输出转换结果。 +如果转换成功,`actualNumber`常量可以在`if`语句的第一个分支中使用。它已经被可选类型_包含的_值初始化过,所以不需要再使用`!`后缀来获取它的值。在这个例子中,`actualNumber`只被用来输出转换结果。 -你可以在可选绑定中使用常量和变量。如果你想在`if`语句的第一个分支中操作`actualNumber`的值,你可以改成`if var actualNumber`,这样可选包含的值就会被赋给一个变量而非常量。 +你可以在可选绑定中使用常量和变量。如果你想在`if`语句的第一个分支中操作`actualNumber`的值,你可以改成`if var actualNumber`,这样可选类型包含的值就会被赋给一个变量而非常量。 ### nil @@ -530,19 +530,19 @@ C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C > 注意: > -Swift 的`nil`和 Objective-C 中的`nil`并不一样。在 Objective-C 中,`nil`是一个指向不存在对象的指针。在 Swift 中,`nil`不是指针——它是一个确定的值,用来表示值缺失。_任何_类型的可选都可以被设置为`nil`,不只是对象类型。 +Swift 的`nil`和 Objective-C 中的`nil`并不一样。在 Objective-C 中,`nil`是一个指向不存在对象的指针。在 Swift 中,`nil`不是指针——它是一个确定的值,用来表示值缺失。_任何_类型的可选状态都可以被设置为`nil`,不只是对象类型。 -### 隐式解析可选 +### 隐式解析可选类型 -如上所述,可选暗示了常量或者变量可以“没有值”。可选可以通过`if`语句来判断是否有值,如果有值的话可以通过可选绑定来解析值。 +如上所述,可选类型暗示了常量或者变量可以“没有值”。可选可以通过`if`语句来判断是否有值,如果有值的话可以通过可选绑定来解析值。 -有时候在程序架构中,第一次被赋值之后,可以确定一个可选_总会_有值。在这种情况下,每次都要判断和解析可选值是非常低效的,因为可以确定它总会有值。 +有时候在程序架构中,第一次被赋值之后,可以确定一个可选类型_总会_有值。在这种情况下,每次都要判断和解析可选值是非常低效的,因为可以确定它总会有值。 -这种类型的可选被定义为_隐式解析可选(implicitly unwrapped optionals)_。把想要用作可选的类型的后面的问号(`String?`)改成感叹号(`String!`)来声明一个隐式解析可选。 +这种类型的可选状态被定义为_隐式解析可选类型(implicitly unwrapped optionals)_。把想要用作可选的类型的后面的问号(`String?`)改成感叹号(`String!`)来声明一个隐式解析可选类型。 -当可选被第一次赋值之后就可以确定之后一直有值的时候,隐式解析可选非常有用。隐式解析可选主要被用在 Swift 中类的构造过程中,请参考[类实例之间的循环强引用](16_Automatic_Reference_Counting.html#strong_reference_cycles_between_class_instances)。 +当可选类型被第一次赋值之后就可以确定之后一直有值的时候,隐式解析可选类型非常有用。隐式解析可选类型主要被用在 Swift 中类的构造过程中,请参考[类实例之间的循环强引用](16_Automatic_Reference_Counting.html#strong_reference_cycles_between_class_instances)。 -一个隐式解析可选其实就是一个普通的可选,但是可以被当做非可选来使用,并不需要每次都使用解析来获取可选值。下面的例子展示了可选`String`和隐式解析可选`String`之间的区别: +一个隐式解析可选类型其实就是一个普通的可选类型,但是可以被当做非可选类型来使用,并不需要每次都使用解析来获取可选值。下面的例子展示了可选类型`String`和隐式解析可选类型`String`之间的区别: let possibleString: String? = "An optional string." println(possibleString!) // 需要惊叹号来获取值 @@ -552,20 +552,20 @@ Swift 的`nil`和 Objective-C 中的`nil`并不一样。在 Objective-C 中,`n println(assumedString) // 不需要感叹号 // 输出 "An implicitly unwrapped optional string." -你可以把隐式解析可选当做一个可以自动解析的可选。你要做的只是声明的时候把感叹号放到类型的结尾,而不是每次取值的可选名字的结尾。 +你可以把隐式解析可选类型当做一个可以自动解析的可选类型。你要做的只是声明的时候把感叹号放到类型的结尾,而不是每次取值的可选名字的结尾。 > 注意: > -如果你在隐式解析可选没有值的时候尝试取值,会触发运行时错误。和你在没有值的普通可选后面加一个惊叹号一样。 +如果你在隐式解析可选类型没有值的时候尝试取值,会触发运行时错误。和你在没有值的普通可选类型后面加一个惊叹号一样。 -你仍然可以把隐式解析可选当做普通可选来判断它是否包含值: +你仍然可以把隐式解析可选类型当做普通可选类型来判断它是否包含值: if assumedString { println(assumedString) } // 输出 "An implicitly unwrapped optional string." -你也可以在可选绑定中使用隐式解析可选来检查并解析它的值: +你也可以在可选绑定中使用隐式解析可选类型来检查并解析它的值: if let definiteString = assumedString { println(definiteString) @@ -574,12 +574,12 @@ Swift 的`nil`和 Objective-C 中的`nil`并不一样。在 Objective-C 中,`n > 注意: > -如果一个变量之后可能变成`nil`的话请不要使用隐式解析可选。如果你需要在变量的生命周期中判断是否是`nil`的话,请使用普通可选类型。 +如果一个变量之后可能变成`nil`的话请不要使用隐式解析可选类型。如果你需要在变量的生命周期中判断是否是`nil`的话,请使用普通可选类型。 ## 断言 -可选可以让你判断值是否存在,你可以在代码中优雅地处理值缺失的情况。然而,在某些情况下,如果值缺失或者值并不满足特定的条件,你的代码可能并不需要继续执行。这时,你可以在你的代码中触发一个_断言(assertion)_来结束代码运行并通过调试来找到值缺失的原因。 +可选类型可以让你判断值是否存在,你可以在代码中优雅地处理值缺失的情况。然而,在某些情况下,如果值缺失或者值并不满足特定的条件,你的代码可能并不需要继续执行。这时,你可以在你的代码中触发一个_断言(assertion)_来结束代码运行并通过调试来找到值缺失的原因。 ### 使用断言进行调试 @@ -603,11 +603,11 @@ Swift 的`nil`和 Objective-C 中的`nil`并不一样。在 Objective-C 中,`n 当条件可能为假时使用断言,但是最终一定要_保证_条件为真,这样你的代码才能继续运行。断言的适用情景: -* 整数的附属脚本索引被传入一个自定义附属脚本实现,但是下标索引值可能太小或者太大。 +* 整数类型的下标索引被传入一个自定义下标脚本实现,但是下标索引值可能太小或者太大。 * 需要给函数传入一个值,但是非法的值可能导致函数不能正常执行。 * 一个可选值现在是`nil`,但是后面的代码运行需要一个非`nil`值。 -请参考[附属脚本](12_Subscripts.html)和[函数](06_Functions.html)。 +请参考[下标脚本](12_Subscripts.html)和[函数](06_Functions.html)。 > 注意: > diff --git a/source/chapter2/02_Basic_Operators.md b/source/chapter2/02_Basic_Operators.md old mode 100644 new mode 100755 diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md old mode 100644 new mode 100755 diff --git a/source/chapter2/04_Collection_Types.md b/source/chapter2/04_Collection_Types.md old mode 100644 new mode 100755 index 76ab248d..df97880f --- a/source/chapter2/04_Collection_Types.md +++ b/source/chapter2/04_Collection_Types.md @@ -24,7 +24,7 @@ Swift 的数组结构在被声明成常量和变量或者被传入函数与方 数组使用有序列表存储相同类型的多重数据。相同的值可以多次出现在一个数组的不同位置中。 -Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray`和`NSMutableArray`类,他们可以存储任何类型的实例而且不提供他们返回对象的任何本质信息。 在 Swift 中,数据值在被存储进入某个数组之前类型必须明确,方法是通过显式的类型标注或类型推断,而且不是必须是`class`类型。例如: 如果我们创建了一个`Int`值类型的数组,我们不能往其中插入任何不是`Int`类型的数据。 Swift 中的数组是类型安全的,并且它们中包含的类型必须明确。 +Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray`和`NSMutableArray`类,它们可以存储任何类型的实例而且不提供它们返回对象的任何本质信息。 在 Swift 中,数据值在被存储进入某个数组之前类型必须明确,方法是通过显式的类型标注或类型推断,而且不是必须是`class`类型。例如: 如果我们创建了一个`Int`值类型的数组,我们不能往其中插入任何不是`Int`类型的数据。 Swift 中的数组是类型安全的,并且它们中包含的类型必须明确。 ### 数组的简单语法 @@ -34,7 +34,7 @@ Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray` ### 数组构造语句 -我们可以使用字面语句来进行数组构造,这是一种用一个或者多个数值构造数组的简单方法。字面语句是一系列由逗号分割并由方括号包含的数值。 +我们可以使用字面量来进行数组构造,这是一种用一个或者多个数值构造数组的简单方法。字面量是一系列由逗号分割并由方括号包含的数值。 `[value 1, value 2, value 3]`。 下面这个例子创建了一个叫做`shoppingList`并且存储字符串的数组: @@ -42,19 +42,19 @@ Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray` var shoppingList: String[] = ["Eggs", "Milk"] // shoppingList 已经被构造并且拥有两个初始项。 -`shoppingList`变量被声明为“字符串值类型的数组“,记作`String[]`。 因为这个数组被规定只有`String`一种数据结构,所以只有`String`类型可以在其中被存取。 在这里,`shoppinglist`数组由两个`String`值(`"Eggs"` 和`"Milk"`)构造,并且由字面语句定义。 +`shoppingList`变量被声明为“字符串值类型的数组“,记作`String[]`。 因为这个数组被规定只有`String`一种数据结构,所以只有`String`类型可以在其中被存取。 在这里,`shoppinglist`数组由两个`String`值(`"Eggs"` 和`"Milk"`)构造,并且由字面量定义。 > 注意: > > `Shoppinglist`数组被声明为变量(`var`关键字创建)而不是常量(`let`创建)是因为以后可能会有更多的数据项被插入其中。 -在这个例子中,字面语句仅仅包含两个`String`值。匹配了该数组的变量声明(只能包含`String`的数组),所以这个字面语句的分配过程就是允许用两个初始项来构造`shoppinglist`。 +在这个例子中,字面量仅仅包含两个`String`值。匹配了该数组的变量声明(只能包含`String`的数组),所以这个字面量的分配过程就是允许用两个初始项来构造`shoppinglist`。 -由于 Swift 的类型推断机制,当我们用字面语句构造只拥有相同类型值数组的时候,我们不必把数组的类型定义清楚。 `shoppinglist`的构造也可以这样写: +由于 Swift 的类型推断机制,当我们用字面量构造只拥有相同类型值数组的时候,我们不必把数组的类型定义清楚。 `shoppinglist`的构造也可以这样写: var shoppingList = ["Eggs", "Milk"] -因为所有字面语句中的值都是相同的类型,Swift 可以推断出`String[]`是`shoppinglist`中变量的正确类型。 +因为所有字面量中的值都是相同的类型,Swift 可以推断出`String[]`是`shoppinglist`中变量的正确类型。 ### 访问和修改数组 @@ -108,7 +108,7 @@ Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray` > 注意: > ->我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行期错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。 +>我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行时错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。 调用数组的`insert(atIndex:)`方法来在某个具体索引值之前添加数据项: @@ -151,7 +151,7 @@ Swift 数组对存储数据有具体要求。 不同于 Objective-C 的`NSArray` // Baking Powder // Bananas -如果我们同时需要每个数据项的值和索引值,可以使用全局`enumerate`函数来进行数组遍历。`enumerate`返回一个由每一个数据项索引值和数据值组成的键值对组。我们可以把这个键值对组分解成临时常量或者变量来进行遍历: +如果我们同时需要每个数据项的值和索引值,可以使用全局`enumerate`函数来进行数组遍历。`enumerate`返回一个由每一个数据项索引值和数据值组成的元组。我们可以把这个元组分解成临时常量或者变量来进行遍历: for (index, value) in enumerate(shoppingList) { println("Item \(index + 1): \(value)") @@ -200,7 +200,7 @@ Swift 中的`Array`类型还提供一个可以创建特定大小并且所有数 ## 字典 -字典是一种存储相同类型多重数据的存储器。每个值(value)都关联独特的键(key),键作为字典中的这个值数据的标识符。和数组中的数据项不同,字典中的数据项并没有具体顺序。我们在需要通过标识符(键)访问数据的时候使用字典,这种方法很大程度上和我们在现实世界中使用字典查字义的方法一样。 +字典是一种存储多个相同类型的值的容器。每个值(value)都关联唯一的键(key),键作为字典中的这个值数据的标识符。和数组中的数据项不同,字典中的数据项并没有具体顺序。我们在需要通过标识符(键)访问数据的时候使用字典,这种方法很大程度上和我们在现实世界中使用字典查字义的方法一样。 Swift 的字典使用时需要具体规定可以存储键和值类型。不同于 Objective-C 的`NSDictionary`和`NSMutableDictionary` 类可以使用任何类型的对象来作键和值并且不提供任何关于这些对象的本质信息。在 Swift 中,在某个特定字典中可以存储的键和值必须提前定义清楚,方法是通过显性类型标注或者类型推断。 @@ -209,11 +209,11 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 `KeyType`的唯一限制就是可哈希的,这样可以保证它是独一无二的,所有的 Swift 基本类型(例如`String`,`Int`, `Double`和`Bool`)都是默认可哈希的,并且所有这些类型都可以在字典中当做键使用。未关联值的枚举成员(参见[枚举](08_Enumerations.html))也是默认可哈希的。 -## 字典字面语句 +## 字典字面量 -我们可以使用字典字面语句来构造字典,他们和我们刚才介绍过的数组字面语句拥有相似语法。一个字典字面语句是一个定义拥有一个或者多个键值对的字典集合的简单语句。 +我们可以使用字典字面量来构造字典,它们和我们刚才介绍过的数组字面量拥有相似语法。一个字典字面量是一个定义拥有一个或者多个键值对的字典集合的简单语句。 -一个键值对是一个`key`和一个`value`的结合体。在字典字面语句中,每一个键值对的键和值都由冒号分割。这些键值对构成一个列表,其中这些键值对由方括号包含并且由逗号分割: +一个键值对是一个`key`和一个`value`的结合体。在字典字面量中,每一个键值对的键和值都由冒号分割。这些键值对构成一个列表,其中这些键值对由方括号包含并且由逗号分割: [key 1: value 1, key 2: value 2, key 3: value 3] @@ -227,11 +227,11 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 > > `airports`字典被声明为变量(用`var`关键字)而不是常量(`let`关键字)因为后来更多的机场信息会被添加到这个示例字典中。 -`airports`字典使用字典字面语句初始化,包含两个键值对。第一对的键是`TYO`,值是`Tokyo`。第二对的键是`DUB`,值是`Dublin`。 +`airports`字典使用字典字面量初始化,包含两个键值对。第一对的键是`TYO`,值是`Tokyo`。第二对的键是`DUB`,值是`Dublin`。 -这个字典语句包含了两个`String: String`类型的键值对。他们对应`airports`变量声明的类型(一个只有`String`键和`String`值的字典)所以这个字典字面语句是构造两个初始数据项的`airport`字典。 +这个字典语句包含了两个`String: String`类型的键值对。它们对应`airports`变量声明的类型(一个只有`String`键和`String`值的字典)所以这个字典字面量是构造两个初始数据项的`airport`字典。 -和数组一样,如果我们使用字面语句构造字典就不用把类型定义清楚。`airports`的也可以用这种方法简短定义: +和数组一样,如果我们使用字面量构造字典就不用把类型定义清楚。`airports`的也可以用这种方法简短定义: var airports = ["TYO": "Tokyo", "DUB": "Dublin"] @@ -292,7 +292,7 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 ### 字典遍历 -我们可以使用`for-in`循环来遍历某个字典中的键值对。每一个字典中的数据项都由`(key, value)`元组形式返回,并且我们可以使用暂时性常量或者变量来分解这些元组: +我们可以使用`for-in`循环来遍历某个字典中的键值对。每一个字典中的数据项都由`(key, value)`元组形式返回,并且我们可以使用临时常量或者变量来分解这些元组: for (airportCode, airportName) in airports { println("\(airportCode): \(airportName)") @@ -301,7 +301,7 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 // LHR: London Heathrow `for-in`循环请参见[For 循环](05_Control_Flow.html#for_loops)。 -我们也可以通过访问他的`keys`或者`values`属性(都是可遍历集合)检索一个字典的键或者值: +我们也可以通过访问它的`keys`或者`values`属性(都是可遍历集合)检索一个字典的键或者值: for airportCode in airports.keys { println("Airport code: \(airportCode)") @@ -337,7 +337,7 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 这个例子创建了一个`Int, String`类型的空字典来储存英语对整数的命名。它的键是`Int`型,值是`String`型。 -如果上下文已经提供了信息类型,我们可以使用空字典字面语句来创建一个空字典,记作`[:]`(中括号中放一个冒号): +如果上下文已经提供了信息类型,我们可以使用空字典字面量来创建一个空字典,记作`[:]`(中括号中放一个冒号): namesOfIntegers[16] = "sixteen" // namesOfIntegers 现在包含一个键值对 @@ -351,7 +351,7 @@ Swift 的字典使用`Dictionary`定义,其中`KeyType`是 ## 集合的可变性 -数组和字典都是在单个集合中存储可变值。如果我们创建一个数组或者字典并且把它分配成一个变量,这个集合将会是可变的。这意味着我们可以在创建之后添加更多或移除已存在的数据项来改变这个集合的大小。与此相反,如果我们把数组或字典分配成常量,那么他就是不可变的,它的大小不能被改变。 +数组和字典都是在单个集合中存储可变值。如果我们创建一个数组或者字典并且把它分配成一个变量,这个集合将会是可变的。这意味着我们可以在创建之后添加更多或移除已存在的数据项来改变这个集合的大小。与此相反,如果我们把数组或字典分配成常量,那么它就是不可变的,它的大小不能被改变。 对字典来说,不可变性也意味着我们不能替换其中任何现有键所对应的值。不可变字典的内容在被首次设定之后不能更改。 不可变性对数组来说有一点不同,当然我们不能试着改变任何不可变数组的大小,但是我们可以重新设定相对现存索引所对应的值。这使得 Swift 数组在大小被固定的时候依然可以做的很棒。 diff --git a/source/chapter2/05_Control_Flow.md b/source/chapter2/05_Control_Flow.md old mode 100644 new mode 100755 index 82d3a5bb..91cf8bcd --- a/source/chapter2/05_Control_Flow.md +++ b/source/chapter2/05_Control_Flow.md @@ -14,7 +14,7 @@ Swift提供了类似 C 语言的流程控制结构,包括可以多次执行任务的`for`和`while`循环,基于特定条件选择执行不同代码分支的`if`和`switch`语句,还有控制流程跳转到其他代码的`break`和`continue`语句。 -除了 C 语言里面传统的for条件递增(`for-condition-increment`)循环,Swift 还增加了`for-in`循环,用来更简单地遍历数组(array),字典(dictionary),区间(range),字符串(string)和其他序列类型。 +除了 C 语言里面传统的 for 条件递增(`for-condition-increment`)循环,Swift 还增加了`for-in`循环,用来更简单地遍历数组(array),字典(dictionary),区间(range),字符串(string)和其他序列类型。 Swift 的`switch`语句比 C 语言中更加强大。在 C 语言中,如果某个 case 不小心漏写了`break`,这个 case 就会贯穿(fallthrough)至下一个 case,Swift 无需写`break`,所以不会发生这种贯穿(fallthrough)的情况。case 还可以匹配更多的类型模式,包括区间匹配(range matching),元组(tuple)和特定类型的描述。`switch`的 case 语句中匹配的值可以是由 case 体内部临时的常量或者变量决定,也可以由`where`分句描述更复杂的匹配条件。 diff --git a/source/chapter2/06_Functions.md b/source/chapter2/06_Functions.md old mode 100644 new mode 100755 diff --git a/source/chapter2/07_Closures.md b/source/chapter2/07_Closures.md old mode 100644 new mode 100755 diff --git a/source/chapter2/08_Enumerations.md b/source/chapter2/08_Enumerations.md old mode 100644 new mode 100755 diff --git a/source/chapter2/09_Classes_and_Structures.md b/source/chapter2/09_Classes_and_Structures.md old mode 100644 new mode 100755 diff --git a/source/chapter2/10_Properties.md b/source/chapter2/10_Properties.md old mode 100644 new mode 100755 diff --git a/source/chapter2/11_Methods.md b/source/chapter2/11_Methods.md old mode 100644 new mode 100755 diff --git a/source/chapter2/12_Subscripts.md b/source/chapter2/12_Subscripts.md old mode 100644 new mode 100755 diff --git a/source/chapter2/13_Inheritance.md b/source/chapter2/13_Inheritance.md old mode 100644 new mode 100755 diff --git a/source/chapter2/14_Initialization.md b/source/chapter2/14_Initialization.md old mode 100644 new mode 100755 diff --git a/source/chapter2/15_Deinitialization.md b/source/chapter2/15_Deinitialization.md old mode 100644 new mode 100755 diff --git a/source/chapter2/16_Automatic_Reference_Counting.md b/source/chapter2/16_Automatic_Reference_Counting.md old mode 100644 new mode 100755 diff --git a/source/chapter2/17_Optional_Chaining.md b/source/chapter2/17_Optional_Chaining.md old mode 100644 new mode 100755 diff --git a/source/chapter2/18_Type_Casting.md b/source/chapter2/18_Type_Casting.md old mode 100644 new mode 100755 diff --git a/source/chapter2/19_Nested_Types.md b/source/chapter2/19_Nested_Types.md old mode 100644 new mode 100755 diff --git a/source/chapter2/20_Extensions.md b/source/chapter2/20_Extensions.md old mode 100644 new mode 100755 diff --git a/source/chapter2/21_Protocols.md b/source/chapter2/21_Protocols.md old mode 100644 new mode 100755 diff --git a/source/chapter2/22_Generics.md b/source/chapter2/22_Generics.md old mode 100644 new mode 100755 diff --git a/source/chapter2/23_Advanced_Operators.md b/source/chapter2/23_Advanced_Operators.md old mode 100644 new mode 100755 diff --git a/source/chapter2/chapter2.md b/source/chapter2/chapter2.md old mode 100644 new mode 100755 diff --git a/source/chapter3/01_About_the_Language_Reference.md b/source/chapter3/01_About_the_Language_Reference.md old mode 100644 new mode 100755 diff --git a/source/chapter3/02_Lexical_Structure.md b/source/chapter3/02_Lexical_Structure.md old mode 100644 new mode 100755 diff --git a/source/chapter3/03_Types.md b/source/chapter3/03_Types.md old mode 100644 new mode 100755 diff --git a/source/chapter3/04_Expressions.md b/source/chapter3/04_Expressions.md old mode 100644 new mode 100755 diff --git a/source/chapter3/05_Declarations.md b/source/chapter3/05_Declarations.md old mode 100644 new mode 100755 diff --git a/source/chapter3/06_Attributes.md b/source/chapter3/06_Attributes.md old mode 100644 new mode 100755 diff --git a/source/chapter3/07_Patterns.md b/source/chapter3/07_Patterns.md old mode 100644 new mode 100755 diff --git a/source/chapter3/08_Generic_Parameters_and_Arguments.md b/source/chapter3/08_Generic_Parameters_and_Arguments.md old mode 100644 new mode 100755 diff --git a/source/chapter3/09_Summary_of_the_Grammar.md b/source/chapter3/09_Summary_of_the_Grammar.md old mode 100644 new mode 100755 diff --git a/source/chapter3/10_Statements.md b/source/chapter3/10_Statements.md old mode 100644 new mode 100755 diff --git a/source/chapter3/chapter3.md b/source/chapter3/chapter3.md old mode 100644 new mode 100755 From 7011436cef10f06d29857fb2c95084d9359f9886 Mon Sep 17 00:00:00 2001 From: wuxing Date: Sat, 14 Jun 2014 15:57:52 +0800 Subject: [PATCH 2/4] modify right back --- CNAME | 0 README.md | 0 .../01Interacting with Objective-C APIs.md | 0 .../03Mix and Match/DAG_2x.png | Bin .../Swift and Objective-C in the Same Project.md | 0 .../03Mix and Match/bridgingheader_2x.png | Bin change_cdn.py | 0 chapter1/01_swift.html | 0 chapter1/02_a_swift_tour.html | 0 chapter1/chapter1.html | 0 chapter2/01_The_Basics.html | 0 chapter2/02_Basic_Operators.html | 0 chapter2/03_Strings_and_Characters.html | 0 chapter2/04_Collection_Types.html | 0 chapter2/05_Control_Flow.html | 0 chapter2/06_Functions.html | 0 chapter2/07_Closures.html | 0 chapter2/08_Enumerations.html | 0 chapter2/09_Classes_and_Structures.html | 0 chapter2/10_Properties.html | 0 chapter2/11_Methods.html | 0 chapter2/12_Subscripts.html | 0 chapter2/13_Inheritance.html | 0 chapter2/14_Initialization.html | 0 chapter2/15_Deinitialization.html | 0 chapter2/16_Automatic_Reference_Counting.html | 0 chapter2/17_Optional_Chaining.html | 0 chapter2/18_Type_Casting.html | 0 chapter2/19_Nested_Types.html | 0 chapter2/20_Extensions.html | 0 chapter2/21_Protocols.html | 0 chapter2/22_Generics.html | 0 chapter2/23_Advanced_Operators.html | 0 chapter2/chapter2.html | 0 chapter3/01_About_the_Language_Reference.html | 0 chapter3/02_Lexical_Structure.html | 0 chapter3/03_Types.html | 0 chapter3/04_Expressions.html | 0 chapter3/05_Declarations.html | 0 chapter3/06_Attributes.html | 0 chapter3/07_Patterns.html | 0 chapter3/08_Generic_Parameters_and_Arguments.html | 0 chapter3/09_Summary_of_the_Grammar.html | 0 chapter3/10_Statements.html | 0 chapter3/chapter3.html | 0 gitbook/app.js | 0 gitbook/fonts/anonymouspro/400.woff | Bin gitbook/fonts/anonymouspro/400i.woff | Bin gitbook/fonts/anonymouspro/700.woff | Bin gitbook/fonts/anonymouspro/700i.woff | Bin gitbook/fonts/ebgaramond/400.woff | Bin gitbook/fonts/ebgaramond/400i.woff | Bin gitbook/fonts/fontawesome/FontAwesome.otf | Bin gitbook/fonts/fontawesome/fontawesome-webfont.eot | Bin gitbook/fonts/fontawesome/fontawesome-webfont.svg | 0 gitbook/fonts/fontawesome/fontawesome-webfont.ttf | Bin gitbook/fonts/fontawesome/fontawesome-webfont.woff | Bin gitbook/fonts/merriweather/250.woff | Bin gitbook/fonts/merriweather/250i.woff | Bin gitbook/fonts/merriweather/400.woff | Bin gitbook/fonts/merriweather/400i.woff | Bin gitbook/fonts/merriweather/700.woff | Bin gitbook/fonts/merriweather/700i.woff | Bin gitbook/fonts/merriweather/900.woff | Bin gitbook/fonts/merriweather/900i.woff | Bin gitbook/fonts/opensans/300.woff | Bin gitbook/fonts/opensans/300i.woff | Bin gitbook/fonts/opensans/400.woff | Bin gitbook/fonts/opensans/400i.woff | Bin gitbook/fonts/opensans/600.woff | Bin gitbook/fonts/opensans/600i.woff | Bin gitbook/fonts/opensans/700.woff | Bin gitbook/fonts/opensans/700i.woff | Bin gitbook/images/favicon.ico | Bin gitbook/jsrepl/engines/javascript-default.js | 0 gitbook/jsrepl/jsrepl.js | 0 gitbook/jsrepl/langs/javascript/jsrepl_js.js | 0 gitbook/jsrepl/sandbox.html | 0 gitbook/jsrepl/sandbox.js | 0 gitbook/plugins/gitbook-plugin-mathjax/plugin.js | 0 gitbook/plugins/gitbook-plugin-mixpanel/plugin.js | 0 gitbook/print.css | 0 gitbook/style.css | 0 googleb0a4f5a22e9cb82f.html | 0 index.html | 0 manifest.appcache | 0 search_index.json | 0 source/README.md | 0 source/SUMMARY.md | 0 source/chapter1/01_swift.md | 0 source/chapter1/02_a_swift_tour.md | 0 source/chapter1/chapter1.md | 0 source/chapter2/01_The_Basics.md | 0 source/chapter2/02_Basic_Operators.md | 0 source/chapter2/03_Strings_and_Characters.md | 0 source/chapter2/04_Collection_Types.md | 0 source/chapter2/05_Control_Flow.md | 0 source/chapter2/06_Functions.md | 0 source/chapter2/07_Closures.md | 0 source/chapter2/08_Enumerations.md | 0 source/chapter2/09_Classes_and_Structures.md | 0 source/chapter2/10_Properties.md | 0 source/chapter2/11_Methods.md | 0 source/chapter2/12_Subscripts.md | 0 source/chapter2/13_Inheritance.md | 0 source/chapter2/14_Initialization.md | 0 source/chapter2/15_Deinitialization.md | 0 source/chapter2/16_Automatic_Reference_Counting.md | 0 source/chapter2/17_Optional_Chaining.md | 0 source/chapter2/18_Type_Casting.md | 0 source/chapter2/19_Nested_Types.md | 0 source/chapter2/20_Extensions.md | 0 source/chapter2/21_Protocols.md | 0 source/chapter2/22_Generics.md | 0 source/chapter2/23_Advanced_Operators.md | 0 source/chapter2/chapter2.md | 0 source/chapter3/01_About_the_Language_Reference.md | 0 source/chapter3/02_Lexical_Structure.md | 0 source/chapter3/03_Types.md | 0 source/chapter3/04_Expressions.md | 0 source/chapter3/05_Declarations.md | 0 source/chapter3/06_Attributes.md | 0 source/chapter3/07_Patterns.md | 0 .../chapter3/08_Generic_Parameters_and_Arguments.md | 0 source/chapter3/09_Summary_of_the_Grammar.md | 0 source/chapter3/10_Statements.md | 0 source/chapter3/chapter3.md | 0 127 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CNAME mode change 100755 => 100644 README.md mode change 100755 => 100644 Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md mode change 100755 => 100644 Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png mode change 100755 => 100644 Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md mode change 100755 => 100644 Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png mode change 100755 => 100644 change_cdn.py mode change 100755 => 100644 chapter1/01_swift.html mode change 100755 => 100644 chapter1/02_a_swift_tour.html mode change 100755 => 100644 chapter1/chapter1.html mode change 100755 => 100644 chapter2/01_The_Basics.html mode change 100755 => 100644 chapter2/02_Basic_Operators.html mode change 100755 => 100644 chapter2/03_Strings_and_Characters.html mode change 100755 => 100644 chapter2/04_Collection_Types.html mode change 100755 => 100644 chapter2/05_Control_Flow.html mode change 100755 => 100644 chapter2/06_Functions.html mode change 100755 => 100644 chapter2/07_Closures.html mode change 100755 => 100644 chapter2/08_Enumerations.html mode change 100755 => 100644 chapter2/09_Classes_and_Structures.html mode change 100755 => 100644 chapter2/10_Properties.html mode change 100755 => 100644 chapter2/11_Methods.html mode change 100755 => 100644 chapter2/12_Subscripts.html mode change 100755 => 100644 chapter2/13_Inheritance.html mode change 100755 => 100644 chapter2/14_Initialization.html mode change 100755 => 100644 chapter2/15_Deinitialization.html mode change 100755 => 100644 chapter2/16_Automatic_Reference_Counting.html mode change 100755 => 100644 chapter2/17_Optional_Chaining.html mode change 100755 => 100644 chapter2/18_Type_Casting.html mode change 100755 => 100644 chapter2/19_Nested_Types.html mode change 100755 => 100644 chapter2/20_Extensions.html mode change 100755 => 100644 chapter2/21_Protocols.html mode change 100755 => 100644 chapter2/22_Generics.html mode change 100755 => 100644 chapter2/23_Advanced_Operators.html mode change 100755 => 100644 chapter2/chapter2.html mode change 100755 => 100644 chapter3/01_About_the_Language_Reference.html mode change 100755 => 100644 chapter3/02_Lexical_Structure.html mode change 100755 => 100644 chapter3/03_Types.html mode change 100755 => 100644 chapter3/04_Expressions.html mode change 100755 => 100644 chapter3/05_Declarations.html mode change 100755 => 100644 chapter3/06_Attributes.html mode change 100755 => 100644 chapter3/07_Patterns.html mode change 100755 => 100644 chapter3/08_Generic_Parameters_and_Arguments.html mode change 100755 => 100644 chapter3/09_Summary_of_the_Grammar.html mode change 100755 => 100644 chapter3/10_Statements.html mode change 100755 => 100644 chapter3/chapter3.html mode change 100755 => 100644 gitbook/app.js mode change 100755 => 100644 gitbook/fonts/anonymouspro/400.woff mode change 100755 => 100644 gitbook/fonts/anonymouspro/400i.woff mode change 100755 => 100644 gitbook/fonts/anonymouspro/700.woff mode change 100755 => 100644 gitbook/fonts/anonymouspro/700i.woff mode change 100755 => 100644 gitbook/fonts/ebgaramond/400.woff mode change 100755 => 100644 gitbook/fonts/ebgaramond/400i.woff mode change 100755 => 100644 gitbook/fonts/fontawesome/FontAwesome.otf mode change 100755 => 100644 gitbook/fonts/fontawesome/fontawesome-webfont.eot mode change 100755 => 100644 gitbook/fonts/fontawesome/fontawesome-webfont.svg mode change 100755 => 100644 gitbook/fonts/fontawesome/fontawesome-webfont.ttf mode change 100755 => 100644 gitbook/fonts/fontawesome/fontawesome-webfont.woff mode change 100755 => 100644 gitbook/fonts/merriweather/250.woff mode change 100755 => 100644 gitbook/fonts/merriweather/250i.woff mode change 100755 => 100644 gitbook/fonts/merriweather/400.woff mode change 100755 => 100644 gitbook/fonts/merriweather/400i.woff mode change 100755 => 100644 gitbook/fonts/merriweather/700.woff mode change 100755 => 100644 gitbook/fonts/merriweather/700i.woff mode change 100755 => 100644 gitbook/fonts/merriweather/900.woff mode change 100755 => 100644 gitbook/fonts/merriweather/900i.woff mode change 100755 => 100644 gitbook/fonts/opensans/300.woff mode change 100755 => 100644 gitbook/fonts/opensans/300i.woff mode change 100755 => 100644 gitbook/fonts/opensans/400.woff mode change 100755 => 100644 gitbook/fonts/opensans/400i.woff mode change 100755 => 100644 gitbook/fonts/opensans/600.woff mode change 100755 => 100644 gitbook/fonts/opensans/600i.woff mode change 100755 => 100644 gitbook/fonts/opensans/700.woff mode change 100755 => 100644 gitbook/fonts/opensans/700i.woff mode change 100755 => 100644 gitbook/images/favicon.ico mode change 100755 => 100644 gitbook/jsrepl/engines/javascript-default.js mode change 100755 => 100644 gitbook/jsrepl/jsrepl.js mode change 100755 => 100644 gitbook/jsrepl/langs/javascript/jsrepl_js.js mode change 100755 => 100644 gitbook/jsrepl/sandbox.html mode change 100755 => 100644 gitbook/jsrepl/sandbox.js mode change 100755 => 100644 gitbook/plugins/gitbook-plugin-mathjax/plugin.js mode change 100755 => 100644 gitbook/plugins/gitbook-plugin-mixpanel/plugin.js mode change 100755 => 100644 gitbook/print.css mode change 100755 => 100644 gitbook/style.css mode change 100755 => 100644 googleb0a4f5a22e9cb82f.html mode change 100755 => 100644 index.html mode change 100755 => 100644 manifest.appcache mode change 100755 => 100644 search_index.json mode change 100755 => 100644 source/README.md mode change 100755 => 100644 source/SUMMARY.md mode change 100755 => 100644 source/chapter1/01_swift.md mode change 100755 => 100644 source/chapter1/02_a_swift_tour.md mode change 100755 => 100644 source/chapter1/chapter1.md mode change 100755 => 100644 source/chapter2/01_The_Basics.md mode change 100755 => 100644 source/chapter2/02_Basic_Operators.md mode change 100755 => 100644 source/chapter2/03_Strings_and_Characters.md mode change 100755 => 100644 source/chapter2/04_Collection_Types.md mode change 100755 => 100644 source/chapter2/05_Control_Flow.md mode change 100755 => 100644 source/chapter2/06_Functions.md mode change 100755 => 100644 source/chapter2/07_Closures.md mode change 100755 => 100644 source/chapter2/08_Enumerations.md mode change 100755 => 100644 source/chapter2/09_Classes_and_Structures.md mode change 100755 => 100644 source/chapter2/10_Properties.md mode change 100755 => 100644 source/chapter2/11_Methods.md mode change 100755 => 100644 source/chapter2/12_Subscripts.md mode change 100755 => 100644 source/chapter2/13_Inheritance.md mode change 100755 => 100644 source/chapter2/14_Initialization.md mode change 100755 => 100644 source/chapter2/15_Deinitialization.md mode change 100755 => 100644 source/chapter2/16_Automatic_Reference_Counting.md mode change 100755 => 100644 source/chapter2/17_Optional_Chaining.md mode change 100755 => 100644 source/chapter2/18_Type_Casting.md mode change 100755 => 100644 source/chapter2/19_Nested_Types.md mode change 100755 => 100644 source/chapter2/20_Extensions.md mode change 100755 => 100644 source/chapter2/21_Protocols.md mode change 100755 => 100644 source/chapter2/22_Generics.md mode change 100755 => 100644 source/chapter2/23_Advanced_Operators.md mode change 100755 => 100644 source/chapter2/chapter2.md mode change 100755 => 100644 source/chapter3/01_About_the_Language_Reference.md mode change 100755 => 100644 source/chapter3/02_Lexical_Structure.md mode change 100755 => 100644 source/chapter3/03_Types.md mode change 100755 => 100644 source/chapter3/04_Expressions.md mode change 100755 => 100644 source/chapter3/05_Declarations.md mode change 100755 => 100644 source/chapter3/06_Attributes.md mode change 100755 => 100644 source/chapter3/07_Patterns.md mode change 100755 => 100644 source/chapter3/08_Generic_Parameters_and_Arguments.md mode change 100755 => 100644 source/chapter3/09_Summary_of_the_Grammar.md mode change 100755 => 100644 source/chapter3/10_Statements.md mode change 100755 => 100644 source/chapter3/chapter3.md diff --git a/CNAME b/CNAME old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md b/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md old mode 100755 new mode 100644 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png old mode 100755 new mode 100644 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md old mode 100755 new mode 100644 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png old mode 100755 new mode 100644 diff --git a/change_cdn.py b/change_cdn.py old mode 100755 new mode 100644 diff --git a/chapter1/01_swift.html b/chapter1/01_swift.html old mode 100755 new mode 100644 diff --git a/chapter1/02_a_swift_tour.html b/chapter1/02_a_swift_tour.html old mode 100755 new mode 100644 diff --git a/chapter1/chapter1.html b/chapter1/chapter1.html old mode 100755 new mode 100644 diff --git a/chapter2/01_The_Basics.html b/chapter2/01_The_Basics.html old mode 100755 new mode 100644 diff --git a/chapter2/02_Basic_Operators.html b/chapter2/02_Basic_Operators.html old mode 100755 new mode 100644 diff --git a/chapter2/03_Strings_and_Characters.html b/chapter2/03_Strings_and_Characters.html old mode 100755 new mode 100644 diff --git a/chapter2/04_Collection_Types.html b/chapter2/04_Collection_Types.html old mode 100755 new mode 100644 diff --git a/chapter2/05_Control_Flow.html b/chapter2/05_Control_Flow.html old mode 100755 new mode 100644 diff --git a/chapter2/06_Functions.html b/chapter2/06_Functions.html old mode 100755 new mode 100644 diff --git a/chapter2/07_Closures.html b/chapter2/07_Closures.html old mode 100755 new mode 100644 diff --git a/chapter2/08_Enumerations.html b/chapter2/08_Enumerations.html old mode 100755 new mode 100644 diff --git a/chapter2/09_Classes_and_Structures.html b/chapter2/09_Classes_and_Structures.html old mode 100755 new mode 100644 diff --git a/chapter2/10_Properties.html b/chapter2/10_Properties.html old mode 100755 new mode 100644 diff --git a/chapter2/11_Methods.html b/chapter2/11_Methods.html old mode 100755 new mode 100644 diff --git a/chapter2/12_Subscripts.html b/chapter2/12_Subscripts.html old mode 100755 new mode 100644 diff --git a/chapter2/13_Inheritance.html b/chapter2/13_Inheritance.html old mode 100755 new mode 100644 diff --git a/chapter2/14_Initialization.html b/chapter2/14_Initialization.html old mode 100755 new mode 100644 diff --git a/chapter2/15_Deinitialization.html b/chapter2/15_Deinitialization.html old mode 100755 new mode 100644 diff --git a/chapter2/16_Automatic_Reference_Counting.html b/chapter2/16_Automatic_Reference_Counting.html old mode 100755 new mode 100644 diff --git a/chapter2/17_Optional_Chaining.html b/chapter2/17_Optional_Chaining.html old mode 100755 new mode 100644 diff --git a/chapter2/18_Type_Casting.html b/chapter2/18_Type_Casting.html old mode 100755 new mode 100644 diff --git a/chapter2/19_Nested_Types.html b/chapter2/19_Nested_Types.html old mode 100755 new mode 100644 diff --git a/chapter2/20_Extensions.html b/chapter2/20_Extensions.html old mode 100755 new mode 100644 diff --git a/chapter2/21_Protocols.html b/chapter2/21_Protocols.html old mode 100755 new mode 100644 diff --git a/chapter2/22_Generics.html b/chapter2/22_Generics.html old mode 100755 new mode 100644 diff --git a/chapter2/23_Advanced_Operators.html b/chapter2/23_Advanced_Operators.html old mode 100755 new mode 100644 diff --git a/chapter2/chapter2.html b/chapter2/chapter2.html old mode 100755 new mode 100644 diff --git a/chapter3/01_About_the_Language_Reference.html b/chapter3/01_About_the_Language_Reference.html old mode 100755 new mode 100644 diff --git a/chapter3/02_Lexical_Structure.html b/chapter3/02_Lexical_Structure.html old mode 100755 new mode 100644 diff --git a/chapter3/03_Types.html b/chapter3/03_Types.html old mode 100755 new mode 100644 diff --git a/chapter3/04_Expressions.html b/chapter3/04_Expressions.html old mode 100755 new mode 100644 diff --git a/chapter3/05_Declarations.html b/chapter3/05_Declarations.html old mode 100755 new mode 100644 diff --git a/chapter3/06_Attributes.html b/chapter3/06_Attributes.html old mode 100755 new mode 100644 diff --git a/chapter3/07_Patterns.html b/chapter3/07_Patterns.html old mode 100755 new mode 100644 diff --git a/chapter3/08_Generic_Parameters_and_Arguments.html b/chapter3/08_Generic_Parameters_and_Arguments.html old mode 100755 new mode 100644 diff --git a/chapter3/09_Summary_of_the_Grammar.html b/chapter3/09_Summary_of_the_Grammar.html old mode 100755 new mode 100644 diff --git a/chapter3/10_Statements.html b/chapter3/10_Statements.html old mode 100755 new mode 100644 diff --git a/chapter3/chapter3.html b/chapter3/chapter3.html old mode 100755 new mode 100644 diff --git a/gitbook/app.js b/gitbook/app.js old mode 100755 new mode 100644 diff --git a/gitbook/fonts/anonymouspro/400.woff b/gitbook/fonts/anonymouspro/400.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/anonymouspro/400i.woff b/gitbook/fonts/anonymouspro/400i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/anonymouspro/700.woff b/gitbook/fonts/anonymouspro/700.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/anonymouspro/700i.woff b/gitbook/fonts/anonymouspro/700i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/ebgaramond/400.woff b/gitbook/fonts/ebgaramond/400.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/ebgaramond/400i.woff b/gitbook/fonts/ebgaramond/400i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/fontawesome/FontAwesome.otf b/gitbook/fonts/fontawesome/FontAwesome.otf old mode 100755 new mode 100644 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.eot b/gitbook/fonts/fontawesome/fontawesome-webfont.eot old mode 100755 new mode 100644 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.svg b/gitbook/fonts/fontawesome/fontawesome-webfont.svg old mode 100755 new mode 100644 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.ttf b/gitbook/fonts/fontawesome/fontawesome-webfont.ttf old mode 100755 new mode 100644 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.woff b/gitbook/fonts/fontawesome/fontawesome-webfont.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/250.woff b/gitbook/fonts/merriweather/250.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/250i.woff b/gitbook/fonts/merriweather/250i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/400.woff b/gitbook/fonts/merriweather/400.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/400i.woff b/gitbook/fonts/merriweather/400i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/700.woff b/gitbook/fonts/merriweather/700.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/700i.woff b/gitbook/fonts/merriweather/700i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/900.woff b/gitbook/fonts/merriweather/900.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/merriweather/900i.woff b/gitbook/fonts/merriweather/900i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/300.woff b/gitbook/fonts/opensans/300.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/300i.woff b/gitbook/fonts/opensans/300i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/400.woff b/gitbook/fonts/opensans/400.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/400i.woff b/gitbook/fonts/opensans/400i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/600.woff b/gitbook/fonts/opensans/600.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/600i.woff b/gitbook/fonts/opensans/600i.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/700.woff b/gitbook/fonts/opensans/700.woff old mode 100755 new mode 100644 diff --git a/gitbook/fonts/opensans/700i.woff b/gitbook/fonts/opensans/700i.woff old mode 100755 new mode 100644 diff --git a/gitbook/images/favicon.ico b/gitbook/images/favicon.ico old mode 100755 new mode 100644 diff --git a/gitbook/jsrepl/engines/javascript-default.js b/gitbook/jsrepl/engines/javascript-default.js old mode 100755 new mode 100644 diff --git a/gitbook/jsrepl/jsrepl.js b/gitbook/jsrepl/jsrepl.js old mode 100755 new mode 100644 diff --git a/gitbook/jsrepl/langs/javascript/jsrepl_js.js b/gitbook/jsrepl/langs/javascript/jsrepl_js.js old mode 100755 new mode 100644 diff --git a/gitbook/jsrepl/sandbox.html b/gitbook/jsrepl/sandbox.html old mode 100755 new mode 100644 diff --git a/gitbook/jsrepl/sandbox.js b/gitbook/jsrepl/sandbox.js old mode 100755 new mode 100644 diff --git a/gitbook/plugins/gitbook-plugin-mathjax/plugin.js b/gitbook/plugins/gitbook-plugin-mathjax/plugin.js old mode 100755 new mode 100644 diff --git a/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js b/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js old mode 100755 new mode 100644 diff --git a/gitbook/print.css b/gitbook/print.css old mode 100755 new mode 100644 diff --git a/gitbook/style.css b/gitbook/style.css old mode 100755 new mode 100644 diff --git a/googleb0a4f5a22e9cb82f.html b/googleb0a4f5a22e9cb82f.html old mode 100755 new mode 100644 diff --git a/index.html b/index.html old mode 100755 new mode 100644 diff --git a/manifest.appcache b/manifest.appcache old mode 100755 new mode 100644 diff --git a/search_index.json b/search_index.json old mode 100755 new mode 100644 diff --git a/source/README.md b/source/README.md old mode 100755 new mode 100644 diff --git a/source/SUMMARY.md b/source/SUMMARY.md old mode 100755 new mode 100644 diff --git a/source/chapter1/01_swift.md b/source/chapter1/01_swift.md old mode 100755 new mode 100644 diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md old mode 100755 new mode 100644 diff --git a/source/chapter1/chapter1.md b/source/chapter1/chapter1.md old mode 100755 new mode 100644 diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md old mode 100755 new mode 100644 diff --git a/source/chapter2/02_Basic_Operators.md b/source/chapter2/02_Basic_Operators.md old mode 100755 new mode 100644 diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md old mode 100755 new mode 100644 diff --git a/source/chapter2/04_Collection_Types.md b/source/chapter2/04_Collection_Types.md old mode 100755 new mode 100644 diff --git a/source/chapter2/05_Control_Flow.md b/source/chapter2/05_Control_Flow.md old mode 100755 new mode 100644 diff --git a/source/chapter2/06_Functions.md b/source/chapter2/06_Functions.md old mode 100755 new mode 100644 diff --git a/source/chapter2/07_Closures.md b/source/chapter2/07_Closures.md old mode 100755 new mode 100644 diff --git a/source/chapter2/08_Enumerations.md b/source/chapter2/08_Enumerations.md old mode 100755 new mode 100644 diff --git a/source/chapter2/09_Classes_and_Structures.md b/source/chapter2/09_Classes_and_Structures.md old mode 100755 new mode 100644 diff --git a/source/chapter2/10_Properties.md b/source/chapter2/10_Properties.md old mode 100755 new mode 100644 diff --git a/source/chapter2/11_Methods.md b/source/chapter2/11_Methods.md old mode 100755 new mode 100644 diff --git a/source/chapter2/12_Subscripts.md b/source/chapter2/12_Subscripts.md old mode 100755 new mode 100644 diff --git a/source/chapter2/13_Inheritance.md b/source/chapter2/13_Inheritance.md old mode 100755 new mode 100644 diff --git a/source/chapter2/14_Initialization.md b/source/chapter2/14_Initialization.md old mode 100755 new mode 100644 diff --git a/source/chapter2/15_Deinitialization.md b/source/chapter2/15_Deinitialization.md old mode 100755 new mode 100644 diff --git a/source/chapter2/16_Automatic_Reference_Counting.md b/source/chapter2/16_Automatic_Reference_Counting.md old mode 100755 new mode 100644 diff --git a/source/chapter2/17_Optional_Chaining.md b/source/chapter2/17_Optional_Chaining.md old mode 100755 new mode 100644 diff --git a/source/chapter2/18_Type_Casting.md b/source/chapter2/18_Type_Casting.md old mode 100755 new mode 100644 diff --git a/source/chapter2/19_Nested_Types.md b/source/chapter2/19_Nested_Types.md old mode 100755 new mode 100644 diff --git a/source/chapter2/20_Extensions.md b/source/chapter2/20_Extensions.md old mode 100755 new mode 100644 diff --git a/source/chapter2/21_Protocols.md b/source/chapter2/21_Protocols.md old mode 100755 new mode 100644 diff --git a/source/chapter2/22_Generics.md b/source/chapter2/22_Generics.md old mode 100755 new mode 100644 diff --git a/source/chapter2/23_Advanced_Operators.md b/source/chapter2/23_Advanced_Operators.md old mode 100755 new mode 100644 diff --git a/source/chapter2/chapter2.md b/source/chapter2/chapter2.md old mode 100755 new mode 100644 diff --git a/source/chapter3/01_About_the_Language_Reference.md b/source/chapter3/01_About_the_Language_Reference.md old mode 100755 new mode 100644 diff --git a/source/chapter3/02_Lexical_Structure.md b/source/chapter3/02_Lexical_Structure.md old mode 100755 new mode 100644 diff --git a/source/chapter3/03_Types.md b/source/chapter3/03_Types.md old mode 100755 new mode 100644 diff --git a/source/chapter3/04_Expressions.md b/source/chapter3/04_Expressions.md old mode 100755 new mode 100644 diff --git a/source/chapter3/05_Declarations.md b/source/chapter3/05_Declarations.md old mode 100755 new mode 100644 diff --git a/source/chapter3/06_Attributes.md b/source/chapter3/06_Attributes.md old mode 100755 new mode 100644 diff --git a/source/chapter3/07_Patterns.md b/source/chapter3/07_Patterns.md old mode 100755 new mode 100644 diff --git a/source/chapter3/08_Generic_Parameters_and_Arguments.md b/source/chapter3/08_Generic_Parameters_and_Arguments.md old mode 100755 new mode 100644 diff --git a/source/chapter3/09_Summary_of_the_Grammar.md b/source/chapter3/09_Summary_of_the_Grammar.md old mode 100755 new mode 100644 diff --git a/source/chapter3/10_Statements.md b/source/chapter3/10_Statements.md old mode 100755 new mode 100644 diff --git a/source/chapter3/chapter3.md b/source/chapter3/chapter3.md old mode 100755 new mode 100644 From 1c10a65bd34219758514408745173b8ef7e5c650 Mon Sep 17 00:00:00 2001 From: wuxing Date: Sat, 14 Jun 2014 16:43:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=A0=87=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CNAME | 0 README.md | 0 .../01Interacting with Objective-C APIs.md | 0 .../03Mix and Match/DAG_2x.png | Bin ...ift and Objective-C in the Same Project.md | 0 .../03Mix and Match/bridgingheader_2x.png | Bin change_cdn.py | 0 chapter1/01_swift.html | 0 chapter1/02_a_swift_tour.html | 0 chapter1/chapter1.html | 0 chapter2/01_The_Basics.html | 0 chapter2/02_Basic_Operators.html | 0 chapter2/03_Strings_and_Characters.html | 0 chapter2/04_Collection_Types.html | 0 chapter2/05_Control_Flow.html | 0 chapter2/06_Functions.html | 0 chapter2/07_Closures.html | 0 chapter2/08_Enumerations.html | 0 chapter2/09_Classes_and_Structures.html | 0 chapter2/10_Properties.html | 0 chapter2/11_Methods.html | 0 chapter2/12_Subscripts.html | 0 chapter2/13_Inheritance.html | 0 chapter2/14_Initialization.html | 0 chapter2/15_Deinitialization.html | 0 chapter2/16_Automatic_Reference_Counting.html | 0 chapter2/17_Optional_Chaining.html | 0 chapter2/18_Type_Casting.html | 0 chapter2/19_Nested_Types.html | 0 chapter2/20_Extensions.html | 0 chapter2/21_Protocols.html | 0 chapter2/22_Generics.html | 0 chapter2/23_Advanced_Operators.html | 0 chapter2/chapter2.html | 0 chapter3/01_About_the_Language_Reference.html | 0 chapter3/02_Lexical_Structure.html | 0 chapter3/03_Types.html | 0 chapter3/04_Expressions.html | 0 chapter3/05_Declarations.html | 0 chapter3/06_Attributes.html | 0 chapter3/07_Patterns.html | 0 .../08_Generic_Parameters_and_Arguments.html | 0 chapter3/09_Summary_of_the_Grammar.html | 0 chapter3/10_Statements.html | 0 chapter3/chapter3.html | 0 gitbook/app.js | 0 gitbook/fonts/anonymouspro/400.woff | Bin gitbook/fonts/anonymouspro/400i.woff | Bin gitbook/fonts/anonymouspro/700.woff | Bin gitbook/fonts/anonymouspro/700i.woff | Bin gitbook/fonts/ebgaramond/400.woff | Bin gitbook/fonts/ebgaramond/400i.woff | Bin gitbook/fonts/fontawesome/FontAwesome.otf | Bin .../fonts/fontawesome/fontawesome-webfont.eot | Bin .../fonts/fontawesome/fontawesome-webfont.svg | 0 .../fonts/fontawesome/fontawesome-webfont.ttf | Bin .../fontawesome/fontawesome-webfont.woff | Bin gitbook/fonts/merriweather/250.woff | Bin gitbook/fonts/merriweather/250i.woff | Bin gitbook/fonts/merriweather/400.woff | Bin gitbook/fonts/merriweather/400i.woff | Bin gitbook/fonts/merriweather/700.woff | Bin gitbook/fonts/merriweather/700i.woff | Bin gitbook/fonts/merriweather/900.woff | Bin gitbook/fonts/merriweather/900i.woff | Bin gitbook/fonts/opensans/300.woff | Bin gitbook/fonts/opensans/300i.woff | Bin gitbook/fonts/opensans/400.woff | Bin gitbook/fonts/opensans/400i.woff | Bin gitbook/fonts/opensans/600.woff | Bin gitbook/fonts/opensans/600i.woff | Bin gitbook/fonts/opensans/700.woff | Bin gitbook/fonts/opensans/700i.woff | Bin gitbook/images/favicon.ico | Bin gitbook/jsrepl/engines/javascript-default.js | 0 gitbook/jsrepl/jsrepl.js | 0 gitbook/jsrepl/langs/javascript/jsrepl_js.js | 0 gitbook/jsrepl/sandbox.html | 0 gitbook/jsrepl/sandbox.js | 0 .../plugins/gitbook-plugin-mathjax/plugin.js | 0 .../plugins/gitbook-plugin-mixpanel/plugin.js | 0 gitbook/print.css | 0 gitbook/style.css | 0 googleb0a4f5a22e9cb82f.html | 0 index.html | 0 manifest.appcache | 0 search_index.json | 0 source/.DS_Store | Bin source/README.md | 0 source/SUMMARY.md | 2 +- source/chapter1/01_swift.md | 0 source/chapter1/02_a_swift_tour.md | 16 +++--- source/chapter1/chapter1.md | 0 source/chapter2/01_The_Basics.md | 0 source/chapter2/02_Basic_Operators.md | 0 source/chapter2/03_Strings_and_Characters.md | 0 source/chapter2/04_Collection_Types.md | 0 source/chapter2/05_Control_Flow.md | 0 source/chapter2/06_Functions.md | 2 +- source/chapter2/07_Closures.md | 0 source/chapter2/08_Enumerations.md | 0 source/chapter2/09_Classes_and_Structures.md | 4 +- source/chapter2/10_Properties.md | 0 source/chapter2/11_Methods.md | 0 source/chapter2/12_Subscripts.md | 52 +++++++++--------- source/chapter2/13_Inheritance.md | 16 +++--- source/chapter2/14_Initialization.md | 0 source/chapter2/15_Deinitialization.md | 0 .../16_Automatic_Reference_Counting.md | 0 source/chapter2/17_Optional_Chaining.md | 0 source/chapter2/18_Type_Casting.md | 0 source/chapter2/19_Nested_Types.md | 0 source/chapter2/20_Extensions.md | 4 +- source/chapter2/21_Protocols.md | 0 source/chapter2/22_Generics.md | 0 source/chapter2/23_Advanced_Operators.md | 0 source/chapter2/chapter2.md | 0 .../01_About_the_Language_Reference.md | 0 source/chapter3/02_Lexical_Structure.md | 0 source/chapter3/03_Types.md | 0 source/chapter3/04_Expressions.md | 8 +-- source/chapter3/05_Declarations.md | 40 +++++++------- source/chapter3/06_Attributes.md | 0 source/chapter3/07_Patterns.md | 0 .../08_Generic_Parameters_and_Arguments.md | 0 source/chapter3/09_Summary_of_the_Grammar.md | 20 +++---- source/chapter3/10_Statements.md | 0 source/chapter3/chapter3.md | 0 128 files changed, 82 insertions(+), 82 deletions(-) mode change 100644 => 100755 CNAME mode change 100644 => 100755 README.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md mode change 100644 => 100755 Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png mode change 100644 => 100755 change_cdn.py mode change 100644 => 100755 chapter1/01_swift.html mode change 100644 => 100755 chapter1/02_a_swift_tour.html mode change 100644 => 100755 chapter1/chapter1.html mode change 100644 => 100755 chapter2/01_The_Basics.html mode change 100644 => 100755 chapter2/02_Basic_Operators.html mode change 100644 => 100755 chapter2/03_Strings_and_Characters.html mode change 100644 => 100755 chapter2/04_Collection_Types.html mode change 100644 => 100755 chapter2/05_Control_Flow.html mode change 100644 => 100755 chapter2/06_Functions.html mode change 100644 => 100755 chapter2/07_Closures.html mode change 100644 => 100755 chapter2/08_Enumerations.html mode change 100644 => 100755 chapter2/09_Classes_and_Structures.html mode change 100644 => 100755 chapter2/10_Properties.html mode change 100644 => 100755 chapter2/11_Methods.html mode change 100644 => 100755 chapter2/12_Subscripts.html mode change 100644 => 100755 chapter2/13_Inheritance.html mode change 100644 => 100755 chapter2/14_Initialization.html mode change 100644 => 100755 chapter2/15_Deinitialization.html mode change 100644 => 100755 chapter2/16_Automatic_Reference_Counting.html mode change 100644 => 100755 chapter2/17_Optional_Chaining.html mode change 100644 => 100755 chapter2/18_Type_Casting.html mode change 100644 => 100755 chapter2/19_Nested_Types.html mode change 100644 => 100755 chapter2/20_Extensions.html mode change 100644 => 100755 chapter2/21_Protocols.html mode change 100644 => 100755 chapter2/22_Generics.html mode change 100644 => 100755 chapter2/23_Advanced_Operators.html mode change 100644 => 100755 chapter2/chapter2.html mode change 100644 => 100755 chapter3/01_About_the_Language_Reference.html mode change 100644 => 100755 chapter3/02_Lexical_Structure.html mode change 100644 => 100755 chapter3/03_Types.html mode change 100644 => 100755 chapter3/04_Expressions.html mode change 100644 => 100755 chapter3/05_Declarations.html mode change 100644 => 100755 chapter3/06_Attributes.html mode change 100644 => 100755 chapter3/07_Patterns.html mode change 100644 => 100755 chapter3/08_Generic_Parameters_and_Arguments.html mode change 100644 => 100755 chapter3/09_Summary_of_the_Grammar.html mode change 100644 => 100755 chapter3/10_Statements.html mode change 100644 => 100755 chapter3/chapter3.html mode change 100644 => 100755 gitbook/app.js mode change 100644 => 100755 gitbook/fonts/anonymouspro/400.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/400i.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/700.woff mode change 100644 => 100755 gitbook/fonts/anonymouspro/700i.woff mode change 100644 => 100755 gitbook/fonts/ebgaramond/400.woff mode change 100644 => 100755 gitbook/fonts/ebgaramond/400i.woff mode change 100644 => 100755 gitbook/fonts/fontawesome/FontAwesome.otf mode change 100644 => 100755 gitbook/fonts/fontawesome/fontawesome-webfont.eot mode change 100644 => 100755 gitbook/fonts/fontawesome/fontawesome-webfont.svg mode change 100644 => 100755 gitbook/fonts/fontawesome/fontawesome-webfont.ttf mode change 100644 => 100755 gitbook/fonts/fontawesome/fontawesome-webfont.woff mode change 100644 => 100755 gitbook/fonts/merriweather/250.woff mode change 100644 => 100755 gitbook/fonts/merriweather/250i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/400.woff mode change 100644 => 100755 gitbook/fonts/merriweather/400i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/700.woff mode change 100644 => 100755 gitbook/fonts/merriweather/700i.woff mode change 100644 => 100755 gitbook/fonts/merriweather/900.woff mode change 100644 => 100755 gitbook/fonts/merriweather/900i.woff mode change 100644 => 100755 gitbook/fonts/opensans/300.woff mode change 100644 => 100755 gitbook/fonts/opensans/300i.woff mode change 100644 => 100755 gitbook/fonts/opensans/400.woff mode change 100644 => 100755 gitbook/fonts/opensans/400i.woff mode change 100644 => 100755 gitbook/fonts/opensans/600.woff mode change 100644 => 100755 gitbook/fonts/opensans/600i.woff mode change 100644 => 100755 gitbook/fonts/opensans/700.woff mode change 100644 => 100755 gitbook/fonts/opensans/700i.woff mode change 100644 => 100755 gitbook/images/favicon.ico mode change 100644 => 100755 gitbook/jsrepl/engines/javascript-default.js mode change 100644 => 100755 gitbook/jsrepl/jsrepl.js mode change 100644 => 100755 gitbook/jsrepl/langs/javascript/jsrepl_js.js mode change 100644 => 100755 gitbook/jsrepl/sandbox.html mode change 100644 => 100755 gitbook/jsrepl/sandbox.js mode change 100644 => 100755 gitbook/plugins/gitbook-plugin-mathjax/plugin.js mode change 100644 => 100755 gitbook/plugins/gitbook-plugin-mixpanel/plugin.js mode change 100644 => 100755 gitbook/print.css mode change 100644 => 100755 gitbook/style.css mode change 100644 => 100755 googleb0a4f5a22e9cb82f.html mode change 100644 => 100755 index.html mode change 100644 => 100755 manifest.appcache mode change 100644 => 100755 search_index.json mode change 100644 => 100755 source/.DS_Store mode change 100644 => 100755 source/README.md mode change 100644 => 100755 source/SUMMARY.md mode change 100644 => 100755 source/chapter1/01_swift.md mode change 100644 => 100755 source/chapter1/02_a_swift_tour.md mode change 100644 => 100755 source/chapter1/chapter1.md mode change 100644 => 100755 source/chapter2/01_The_Basics.md mode change 100644 => 100755 source/chapter2/02_Basic_Operators.md mode change 100644 => 100755 source/chapter2/03_Strings_and_Characters.md mode change 100644 => 100755 source/chapter2/04_Collection_Types.md mode change 100644 => 100755 source/chapter2/05_Control_Flow.md mode change 100644 => 100755 source/chapter2/06_Functions.md mode change 100644 => 100755 source/chapter2/07_Closures.md mode change 100644 => 100755 source/chapter2/08_Enumerations.md mode change 100644 => 100755 source/chapter2/09_Classes_and_Structures.md mode change 100644 => 100755 source/chapter2/10_Properties.md mode change 100644 => 100755 source/chapter2/11_Methods.md mode change 100644 => 100755 source/chapter2/12_Subscripts.md mode change 100644 => 100755 source/chapter2/13_Inheritance.md mode change 100644 => 100755 source/chapter2/14_Initialization.md mode change 100644 => 100755 source/chapter2/15_Deinitialization.md mode change 100644 => 100755 source/chapter2/16_Automatic_Reference_Counting.md mode change 100644 => 100755 source/chapter2/17_Optional_Chaining.md mode change 100644 => 100755 source/chapter2/18_Type_Casting.md mode change 100644 => 100755 source/chapter2/19_Nested_Types.md mode change 100644 => 100755 source/chapter2/20_Extensions.md mode change 100644 => 100755 source/chapter2/21_Protocols.md mode change 100644 => 100755 source/chapter2/22_Generics.md mode change 100644 => 100755 source/chapter2/23_Advanced_Operators.md mode change 100644 => 100755 source/chapter2/chapter2.md mode change 100644 => 100755 source/chapter3/01_About_the_Language_Reference.md mode change 100644 => 100755 source/chapter3/02_Lexical_Structure.md mode change 100644 => 100755 source/chapter3/03_Types.md mode change 100644 => 100755 source/chapter3/04_Expressions.md mode change 100644 => 100755 source/chapter3/05_Declarations.md mode change 100644 => 100755 source/chapter3/06_Attributes.md mode change 100644 => 100755 source/chapter3/07_Patterns.md mode change 100644 => 100755 source/chapter3/08_Generic_Parameters_and_Arguments.md mode change 100644 => 100755 source/chapter3/09_Summary_of_the_Grammar.md mode change 100644 => 100755 source/chapter3/10_Statements.md mode change 100644 => 100755 source/chapter3/chapter3.md diff --git a/CNAME b/CNAME old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md b/Using Swift with Cocoa and ObjectiveC/02Interoperability/01Interacting with Objective-C APIs.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/DAG_2x.png old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/Swift and Objective-C in the Same Project.md old mode 100644 new mode 100755 diff --git a/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png b/Using Swift with Cocoa and ObjectiveC/03Mix and Match/bridgingheader_2x.png old mode 100644 new mode 100755 diff --git a/change_cdn.py b/change_cdn.py old mode 100644 new mode 100755 diff --git a/chapter1/01_swift.html b/chapter1/01_swift.html old mode 100644 new mode 100755 diff --git a/chapter1/02_a_swift_tour.html b/chapter1/02_a_swift_tour.html old mode 100644 new mode 100755 diff --git a/chapter1/chapter1.html b/chapter1/chapter1.html old mode 100644 new mode 100755 diff --git a/chapter2/01_The_Basics.html b/chapter2/01_The_Basics.html old mode 100644 new mode 100755 diff --git a/chapter2/02_Basic_Operators.html b/chapter2/02_Basic_Operators.html old mode 100644 new mode 100755 diff --git a/chapter2/03_Strings_and_Characters.html b/chapter2/03_Strings_and_Characters.html old mode 100644 new mode 100755 diff --git a/chapter2/04_Collection_Types.html b/chapter2/04_Collection_Types.html old mode 100644 new mode 100755 diff --git a/chapter2/05_Control_Flow.html b/chapter2/05_Control_Flow.html old mode 100644 new mode 100755 diff --git a/chapter2/06_Functions.html b/chapter2/06_Functions.html old mode 100644 new mode 100755 diff --git a/chapter2/07_Closures.html b/chapter2/07_Closures.html old mode 100644 new mode 100755 diff --git a/chapter2/08_Enumerations.html b/chapter2/08_Enumerations.html old mode 100644 new mode 100755 diff --git a/chapter2/09_Classes_and_Structures.html b/chapter2/09_Classes_and_Structures.html old mode 100644 new mode 100755 diff --git a/chapter2/10_Properties.html b/chapter2/10_Properties.html old mode 100644 new mode 100755 diff --git a/chapter2/11_Methods.html b/chapter2/11_Methods.html old mode 100644 new mode 100755 diff --git a/chapter2/12_Subscripts.html b/chapter2/12_Subscripts.html old mode 100644 new mode 100755 diff --git a/chapter2/13_Inheritance.html b/chapter2/13_Inheritance.html old mode 100644 new mode 100755 diff --git a/chapter2/14_Initialization.html b/chapter2/14_Initialization.html old mode 100644 new mode 100755 diff --git a/chapter2/15_Deinitialization.html b/chapter2/15_Deinitialization.html old mode 100644 new mode 100755 diff --git a/chapter2/16_Automatic_Reference_Counting.html b/chapter2/16_Automatic_Reference_Counting.html old mode 100644 new mode 100755 diff --git a/chapter2/17_Optional_Chaining.html b/chapter2/17_Optional_Chaining.html old mode 100644 new mode 100755 diff --git a/chapter2/18_Type_Casting.html b/chapter2/18_Type_Casting.html old mode 100644 new mode 100755 diff --git a/chapter2/19_Nested_Types.html b/chapter2/19_Nested_Types.html old mode 100644 new mode 100755 diff --git a/chapter2/20_Extensions.html b/chapter2/20_Extensions.html old mode 100644 new mode 100755 diff --git a/chapter2/21_Protocols.html b/chapter2/21_Protocols.html old mode 100644 new mode 100755 diff --git a/chapter2/22_Generics.html b/chapter2/22_Generics.html old mode 100644 new mode 100755 diff --git a/chapter2/23_Advanced_Operators.html b/chapter2/23_Advanced_Operators.html old mode 100644 new mode 100755 diff --git a/chapter2/chapter2.html b/chapter2/chapter2.html old mode 100644 new mode 100755 diff --git a/chapter3/01_About_the_Language_Reference.html b/chapter3/01_About_the_Language_Reference.html old mode 100644 new mode 100755 diff --git a/chapter3/02_Lexical_Structure.html b/chapter3/02_Lexical_Structure.html old mode 100644 new mode 100755 diff --git a/chapter3/03_Types.html b/chapter3/03_Types.html old mode 100644 new mode 100755 diff --git a/chapter3/04_Expressions.html b/chapter3/04_Expressions.html old mode 100644 new mode 100755 diff --git a/chapter3/05_Declarations.html b/chapter3/05_Declarations.html old mode 100644 new mode 100755 diff --git a/chapter3/06_Attributes.html b/chapter3/06_Attributes.html old mode 100644 new mode 100755 diff --git a/chapter3/07_Patterns.html b/chapter3/07_Patterns.html old mode 100644 new mode 100755 diff --git a/chapter3/08_Generic_Parameters_and_Arguments.html b/chapter3/08_Generic_Parameters_and_Arguments.html old mode 100644 new mode 100755 diff --git a/chapter3/09_Summary_of_the_Grammar.html b/chapter3/09_Summary_of_the_Grammar.html old mode 100644 new mode 100755 diff --git a/chapter3/10_Statements.html b/chapter3/10_Statements.html old mode 100644 new mode 100755 diff --git a/chapter3/chapter3.html b/chapter3/chapter3.html old mode 100644 new mode 100755 diff --git a/gitbook/app.js b/gitbook/app.js old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/400.woff b/gitbook/fonts/anonymouspro/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/400i.woff b/gitbook/fonts/anonymouspro/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/700.woff b/gitbook/fonts/anonymouspro/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/anonymouspro/700i.woff b/gitbook/fonts/anonymouspro/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/ebgaramond/400.woff b/gitbook/fonts/ebgaramond/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/ebgaramond/400i.woff b/gitbook/fonts/ebgaramond/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/fontawesome/FontAwesome.otf b/gitbook/fonts/fontawesome/FontAwesome.otf old mode 100644 new mode 100755 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.eot b/gitbook/fonts/fontawesome/fontawesome-webfont.eot old mode 100644 new mode 100755 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.svg b/gitbook/fonts/fontawesome/fontawesome-webfont.svg old mode 100644 new mode 100755 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.ttf b/gitbook/fonts/fontawesome/fontawesome-webfont.ttf old mode 100644 new mode 100755 diff --git a/gitbook/fonts/fontawesome/fontawesome-webfont.woff b/gitbook/fonts/fontawesome/fontawesome-webfont.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/250.woff b/gitbook/fonts/merriweather/250.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/250i.woff b/gitbook/fonts/merriweather/250i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/400.woff b/gitbook/fonts/merriweather/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/400i.woff b/gitbook/fonts/merriweather/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/700.woff b/gitbook/fonts/merriweather/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/700i.woff b/gitbook/fonts/merriweather/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/900.woff b/gitbook/fonts/merriweather/900.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/merriweather/900i.woff b/gitbook/fonts/merriweather/900i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/300.woff b/gitbook/fonts/opensans/300.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/300i.woff b/gitbook/fonts/opensans/300i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/400.woff b/gitbook/fonts/opensans/400.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/400i.woff b/gitbook/fonts/opensans/400i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/600.woff b/gitbook/fonts/opensans/600.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/600i.woff b/gitbook/fonts/opensans/600i.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/700.woff b/gitbook/fonts/opensans/700.woff old mode 100644 new mode 100755 diff --git a/gitbook/fonts/opensans/700i.woff b/gitbook/fonts/opensans/700i.woff old mode 100644 new mode 100755 diff --git a/gitbook/images/favicon.ico b/gitbook/images/favicon.ico old mode 100644 new mode 100755 diff --git a/gitbook/jsrepl/engines/javascript-default.js b/gitbook/jsrepl/engines/javascript-default.js old mode 100644 new mode 100755 diff --git a/gitbook/jsrepl/jsrepl.js b/gitbook/jsrepl/jsrepl.js old mode 100644 new mode 100755 diff --git a/gitbook/jsrepl/langs/javascript/jsrepl_js.js b/gitbook/jsrepl/langs/javascript/jsrepl_js.js old mode 100644 new mode 100755 diff --git a/gitbook/jsrepl/sandbox.html b/gitbook/jsrepl/sandbox.html old mode 100644 new mode 100755 diff --git a/gitbook/jsrepl/sandbox.js b/gitbook/jsrepl/sandbox.js old mode 100644 new mode 100755 diff --git a/gitbook/plugins/gitbook-plugin-mathjax/plugin.js b/gitbook/plugins/gitbook-plugin-mathjax/plugin.js old mode 100644 new mode 100755 diff --git a/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js b/gitbook/plugins/gitbook-plugin-mixpanel/plugin.js old mode 100644 new mode 100755 diff --git a/gitbook/print.css b/gitbook/print.css old mode 100644 new mode 100755 diff --git a/gitbook/style.css b/gitbook/style.css old mode 100644 new mode 100755 diff --git a/googleb0a4f5a22e9cb82f.html b/googleb0a4f5a22e9cb82f.html old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 diff --git a/manifest.appcache b/manifest.appcache old mode 100644 new mode 100755 diff --git a/search_index.json b/search_index.json old mode 100644 new mode 100755 diff --git a/source/.DS_Store b/source/.DS_Store old mode 100644 new mode 100755 diff --git a/source/README.md b/source/README.md old mode 100644 new mode 100755 diff --git a/source/SUMMARY.md b/source/SUMMARY.md old mode 100644 new mode 100755 index c6648ad6..7941f129 --- a/source/SUMMARY.md +++ b/source/SUMMARY.md @@ -15,7 +15,7 @@ * [类和结构体](chapter2/09_Classes_and_Structures.md) * [属性](chapter2/10_Properties.md) * [方法](chapter2/11_Methods.md) - * [附属脚本](chapter2/12_Subscripts.md) + * [下标脚本](chapter2/12_Subscripts.md) * [继承](chapter2/13_Inheritance.md) * [构造过程](chapter2/14_Initialization.md) * [析构过程](chapter2/15_Deinitialization.md) diff --git a/source/chapter1/01_swift.md b/source/chapter1/01_swift.md old mode 100644 new mode 100755 diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md old mode 100644 new mode 100755 index 7fe1554a..5785147e --- a/source/chapter1/02_a_swift_tour.md +++ b/source/chapter1/02_a_swift_tour.md @@ -12,7 +12,7 @@ - [函数和闭包(Functions and Closures)](#functions_and_closures) - [对象和类(Objects and Classes)](#objects_and_classes) - [枚举和结构体(Enumerations and Structures)](#enumerations_and_structures) -- [接口和扩展(Protocols and Extensions)](#protocols_and_extensions) +- [协议和扩展(Protocols and Extensions)](#protocols_and_extensions) - [泛型(Generics)](#generics) 通常来说,编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在 Swift 中,可以用一行代码实现: @@ -623,9 +623,9 @@ 注意如何从`ServerResponse`中提取日升和日落时间。 -## 接口和扩展 +## 协议和扩展 -使用`protocol`来声明一个接口。 +使用`protocol`来声明一个协议。 ```swift protocol ExampleProtocol { @@ -634,7 +634,7 @@ } ``` -类、枚举和结构体都可以实现接口。 +类、枚举和结构体都可以实现协议。 ```swift class SimpleClass: ExampleProtocol { @@ -661,7 +661,7 @@ > 练习: > -> 写一个实现这个接口的枚举。 +> 写一个实现这个协议的枚举。 注意声明`SimpleStructure`时候`mutating`关键字用来标记一个会修改结构体的方法。`SimpleClass`的声明不需要标记任何方法因为类中的方法经常会修改类。 @@ -683,7 +683,7 @@ > > 给`Double`类型写一个扩展,添加`absoluteValue`功能。 -你可以像使用其他命名类型一样使用接口名——例如,创建一个有不同类型但是都实现一个接口的对象集合。当你处理类型是接口的值时,接口外定义的方法不可用。 +你可以像使用其他命名类型一样使用协议名——例如,创建一个有不同类型但是都实现一个协议的对象集合。当你处理类型是协议的值时,协议外定义的方法不可用。 ```swift let protocolValue: ExampleProtocol = a @@ -691,7 +691,7 @@ // protocolValue.anotherProperty // Uncomment to see the error ``` -即使`protocolValue`变量运行时的类型是`simpleClass`,编译器会把它的类型当做`ExampleProtocol`。这表示你不能调用类在它实现的接口之外实现的方法或者属性。 +即使`protocolValue`变量运行时的类型是`simpleClass`,编译器会把它的类型当做`ExampleProtocol`。这表示你不能调用类在它实现的协议之外实现的方法或者属性。 ## 泛型 @@ -741,4 +741,4 @@ > > 修改`anyCommonElements`函数来创建一个函数,返回一个数组,内容是两个序列的共有元素。 -简单起见,你可以忽略`where`,只在冒号后面写接口或者类名。` `和``是等价的。 +简单起见,你可以忽略`where`,只在冒号后面写协议或者类名。` `和``是等价的。 diff --git a/source/chapter1/chapter1.md b/source/chapter1/chapter1.md old mode 100644 new mode 100755 diff --git a/source/chapter2/01_The_Basics.md b/source/chapter2/01_The_Basics.md old mode 100644 new mode 100755 diff --git a/source/chapter2/02_Basic_Operators.md b/source/chapter2/02_Basic_Operators.md old mode 100644 new mode 100755 diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md old mode 100644 new mode 100755 diff --git a/source/chapter2/04_Collection_Types.md b/source/chapter2/04_Collection_Types.md old mode 100644 new mode 100755 diff --git a/source/chapter2/05_Control_Flow.md b/source/chapter2/05_Control_Flow.md old mode 100644 new mode 100755 diff --git a/source/chapter2/06_Functions.md b/source/chapter2/06_Functions.md old mode 100644 new mode 100755 index 0e3fb9b8..4c7fea36 --- a/source/chapter2/06_Functions.md +++ b/source/chapter2/06_Functions.md @@ -471,7 +471,7 @@ println("Result: \(mathFunction(2, 3))") // prints "Result: 6" ``` -就像其他类型一样,当赋值一个函数给常量或变量时,你可以让 Swift 来推测其函数类型: +就像其他类型一样,当赋值一个函数给常量或变量时,你可以让 Swift 来推断其函数类型: ```swift let anotherMathFunction = addTwoInts diff --git a/source/chapter2/07_Closures.md b/source/chapter2/07_Closures.md old mode 100644 new mode 100755 diff --git a/source/chapter2/08_Enumerations.md b/source/chapter2/08_Enumerations.md old mode 100644 new mode 100755 diff --git a/source/chapter2/09_Classes_and_Structures.md b/source/chapter2/09_Classes_and_Structures.md old mode 100644 new mode 100755 index 7553319d..5c514811 --- a/source/chapter2/09_Classes_and_Structures.md +++ b/source/chapter2/09_Classes_and_Structures.md @@ -26,12 +26,12 @@ Swift 中类和结构体有很多共同点。共同处在于: * 定义属性用于储存值 * 定义方法用于提供功能 -* 定义附属脚本用于访问值 +* 定义下标脚本用于访问值 * 定义构造器用于生成初始化值 * 通过扩展以增加默认实现的功能 * 符合协议以对某类提供标准功能 -更多信息请参见 [属性](10_Properties.html),[方法](11_Methods.html),[附属脚本](12_Subscripts.html),[初始过程](14_Initialization.html),[扩展](20_Extensions.html),和[协议](21_Protocols.html)。 +更多信息请参见 [属性](10_Properties.html),[方法](11_Methods.html),[下标脚本](12_Subscripts.html),[初始过程](14_Initialization.html),[扩展](20_Extensions.html),和[协议](21_Protocols.html)。 与结构体相比,类还有如下的附加功能: diff --git a/source/chapter2/10_Properties.md b/source/chapter2/10_Properties.md old mode 100644 new mode 100755 diff --git a/source/chapter2/11_Methods.md b/source/chapter2/11_Methods.md old mode 100644 new mode 100755 diff --git a/source/chapter2/12_Subscripts.md b/source/chapter2/12_Subscripts.md old mode 100644 new mode 100755 index 21af3d06..d37da82b --- a/source/chapter2/12_Subscripts.md +++ b/source/chapter2/12_Subscripts.md @@ -3,25 +3,25 @@ > 校对:zq54zquan -# 附属脚本(Subscripts) +# 下标脚本(Subscripts) ----------------- 本页包含内容: -- [附属脚本语法](#subscript_syntax) -- [附属脚本用法](#subscript_usage) -- [附属脚本选项](#subscript_options) +- [下标脚本语法](#subscript_syntax) +- [下标脚本用法](#subscript_usage) +- [下标脚本选项](#subscript_options) -*附属脚本* 可以定义在类(Class)、结构体(structure)和枚举(enumeration)这些目标中,可以认为是访问对象、集合或序列的快捷方式,不需要再调用实例的特定的赋值和访问方法。举例来说,用附属脚本访问一个数组(Array)实例中的元素可以这样写 `someArray[index]` ,访问字典(Dictionary)实例中的元素可以这样写 `someDictionary[key]`。 +*下标脚本* 可以定义在类(Class)、结构体(structure)和枚举(enumeration)这些目标中,可以认为是访问对象、集合或序列的快捷方式,不需要再调用实例的特定的赋值和访问方法。举例来说,用下标脚本访问一个数组(Array)实例中的元素可以这样写 `someArray[index]` ,访问字典(Dictionary)实例中的元素可以这样写 `someDictionary[key]`。 -对于同一个目标可以定义多个附属脚本,通过索引值类型的不同来进行重载,而且索引值的个数可以是多个。 +对于同一个目标可以定义多个下标脚本,通过索引值类型的不同来进行重载,而且索引值的个数可以是多个。 -> 译者:这里附属脚本重载在本小节中原文并没有任何演示 +> 译者:这里下标脚本重载在本小节中原文并没有任何演示 -## 附属脚本语法 +## 下标脚本语法 -附属脚本允许你通过在实例后面的方括号中传入一个或者多个的索引值来对实例进行访问和赋值。语法类似于实例方法和计算型属性的混合。与定义实例方法类似,定义附属脚本使用`subscript`关键字,显式声明入参(一个或多个)和返回类型。与实例方法不同的是附属脚本可以设定为读写或只读。这种方式又有点像计算型属性的getter和setter: +下标脚本允许你通过在实例后面的方括号中传入一个或者多个的索引值来对实例进行访问和赋值。语法类似于实例方法和计算型属性的混合。与定义实例方法类似,定义下标脚本使用`subscript`关键字,显式声明入参(一个或多个)和返回类型。与实例方法不同的是下标脚本可以设定为读写或只读。这种方式又有点像计算型属性的getter和setter: ``` subscript(index: Int) -> Int { @@ -35,7 +35,7 @@ subscript(index: Int) -> Int { } ``` -`newValue`的类型必须和附属脚本定义的返回类型相同。与计算型属性相同的是set的入参声明`newValue`就算不写,在set代码块中依然可以使用默认的`newValue`这个变量来访问新赋的值。 +`newValue`的类型必须和下标脚本定义的返回类型相同。与计算型属性相同的是set的入参声明`newValue`就算不写,在set代码块中依然可以使用默认的`newValue`这个变量来访问新赋的值。 与只读计算型属性一样,可以直接将原本应该写在`get`代码块中的代码写在`subscript`中: @@ -45,7 +45,7 @@ subscript(index: Int) -> Int { } ``` -下面代码演示了一个在`TimesTable`结构体中使用只读附属脚本的用法,该结构体用来展示传入整数的*n*倍。 +下面代码演示了一个在`TimesTable`结构体中使用只读下标脚本的用法,该结构体用来展示传入整数的*n*倍。 ``` struct TimesTable { @@ -61,41 +61,41 @@ println("3的6倍是\(threeTimesTable[6])") 在上例中,通过`TimesTable`结构体创建了一个用来表示索引值三倍的实例。数值`3`作为结构体`构造函数`入参初始化实例成员`multiplier`。 -你可以通过附属脚本来得到结果,比如`threeTimesTable[6]`。这条语句访问了`threeTimesTable`的第六个元素,返回`6`的`3`倍即`18`。 +你可以通过下标脚本来得到结果,比如`threeTimesTable[6]`。这条语句访问了`threeTimesTable`的第六个元素,返回`6`的`3`倍即`18`。 >注意: > -> `TimesTable`例子是基于一个固定的数学公式。它并不适合开放写权限来对`threeTimesTable[someIndex]`进行赋值操作,这也是为什么附属脚本只定义为只读的原因。 +> `TimesTable`例子是基于一个固定的数学公式。它并不适合开放写权限来对`threeTimesTable[someIndex]`进行赋值操作,这也是为什么下标脚本只定义为只读的原因。 -## 附属脚本用法 +## 下标脚本用法 -根据使用场景不同附属脚本也具有不同的含义。通常附属脚本是用来访问集合(collection),列表(list)或序列(sequence)中元素的快捷方式。你可以在你自己特定的类或结构体中自由的实现附属脚本来提供合适的功能。 +根据使用场景不同下标脚本也具有不同的含义。通常下标脚本是用来访问集合(collection),列表(list)或序列(sequence)中元素的快捷方式。你可以在你自己特定的类或结构体中自由的实现下标脚本来提供合适的功能。 -例如,Swift 的字典(Dictionary)实现了通过附属脚本来对其实例中存放的值进行存取操作。在附属脚本中使用和字典索引相同类型的值,并且把一个字典值类型的值赋值给这个附属脚本来为字典设值: +例如,Swift 的字典(Dictionary)实现了通过下标脚本来对其实例中存放的值进行存取操作。在下标脚本中使用和字典索引相同类型的值,并且把一个字典值类型的值赋值给这个下标脚本来为字典设值: ``` var numberOfLegs = ["spider": 8, "ant": 6, "cat": 4] numberOfLegs["bird"] = 2 ``` -上例定义一个名为`numberOfLegs`的变量并用一个字典字面量初始化出了包含三对键值的字典实例。`numberOfLegs`的字典存放值类型推断为`Dictionary`。字典实例创建完成之后通过附属脚本的方式将整型值`2`赋值到字典实例的索引为`bird`的位置中。 +上例定义一个名为`numberOfLegs`的变量并用一个字典字面量初始化出了包含三对键值的字典实例。`numberOfLegs`的字典存放值类型推断为`Dictionary`。字典实例创建完成之后通过下标脚本的方式将整型值`2`赋值到字典实例的索引为`bird`的位置中。 -更多关于字典(Dictionary)附属脚本的信息请参考[读取和修改字典](../chapter2/04_Collection_Types.html) +更多关于字典(Dictionary)下标脚本的信息请参考[读取和修改字典](../chapter2/04_Collection_Types.html) > 注意: > -> Swift 中字典的附属脚本实现中,在`get`部分返回值是`Int?`,上例中的`numberOfLegs`字典通过附属脚本返回的是一个`Int?`或者说“可选的int”,不是每个字典的索引都能得到一个整型值,对于没有设过值的索引的访问返回的结果就是`nil`;同样想要从字典实例中删除某个索引下的值也只需要给这个索引赋值为`nil`即可。 +> Swift 中字典的下标脚本实现中,在`get`部分返回值是`Int?`,上例中的`numberOfLegs`字典通过下标脚本返回的是一个`Int?`或者说“可选的int”,不是每个字典的索引都能得到一个整型值,对于没有设过值的索引的访问返回的结果就是`nil`;同样想要从字典实例中删除某个索引下的值也只需要给这个索引赋值为`nil`即可。 -## 附属脚本选项 +## 下标脚本选项 -附属脚本允许任意数量的入参索引,并且每个入参类型也没有限制。附属脚本的返回值也可以是任何类型。附属脚本可以使用变量参数和可变参数,但使用写入读出(in-out)参数或给参数设置默认值都是不允许的。 +下标脚本允许任意数量的入参索引,并且每个入参类型也没有限制。下标脚本的返回值也可以是任何类型。下标脚本可以使用变量参数和可变参数,但使用写入读出(in-out)参数或给参数设置默认值都是不允许的。 -一个类或结构体可以根据自身需要提供多个附属脚本实现,在定义附属脚本时通过入参个类型进行区分,使用附属脚本时会自动匹配合适的附属脚本实现运行,这就是*附属脚本的重载*。 +一个类或结构体可以根据自身需要提供多个下标脚本实现,在定义下标脚本时通过入参个类型进行区分,使用下标脚本时会自动匹配合适的下标脚本实现运行,这就是*下标脚本的重载*。 -一个附属脚本入参是最常见的情况,但只要有合适的场景也可以定义多个附属脚本入参。如下例定义了一个`Matrix`结构体,将呈现一个`Double`类型的二维矩阵。`Matrix`结构体的附属脚本需要两个整型参数: +一个下标脚本入参是最常见的情况,但只要有合适的场景也可以定义多个下标脚本入参。如下例定义了一个`Matrix`结构体,将呈现一个`Double`类型的二维矩阵。`Matrix`结构体的下标脚本需要两个整型参数: ``` struct Matrix { @@ -141,7 +141,7 @@ row0 [0.0, 0.0, row1 0.0, 0.0] ``` -将值赋给带有`row`和`column`附属脚本的`matrix`实例表达式可以完成赋值操作,附属脚本入参使用逗号分割 +将值赋给带有`row`和`column`下标脚本的`matrix`实例表达式可以完成赋值操作,下标脚本入参使用逗号分割 ``` matrix[0, 1] = 1.5 @@ -155,7 +155,7 @@ matrix[1, 0] = 3.2 3.2, 0.0] ``` -`Matrix`附属脚本的`getter`和`setter`中同时调用了附属脚本入参的`row`和`column`是否有效的判断。为了方便进行断言,`Matrix`包含了一个名为`indexIsValid`的成员方法,用来确认入参的`row`或`column`值是否会造成数组越界: +`Matrix`下标脚本的`getter`和`setter`中同时调用了下标脚本入参的`row`和`column`是否有效的判断。为了方便进行断言,`Matrix`包含了一个名为`indexIsValid`的成员方法,用来确认入参的`row`或`column`值是否会造成数组越界: ``` func indexIsValidForRow(row: Int, column: Int) -> Bool { @@ -163,7 +163,7 @@ func indexIsValidForRow(row: Int, column: Int) -> Bool { } ``` -断言在附属脚本越界时触发: +断言在下标脚本越界时触发: ``` let someValue = matrix[2, 2] diff --git a/source/chapter2/13_Inheritance.md b/source/chapter2/13_Inheritance.md old mode 100644 new mode 100755 index 69c91a17..f30a260d --- a/source/chapter2/13_Inheritance.md +++ b/source/chapter2/13_Inheritance.md @@ -14,7 +14,7 @@ 一个类可以*继承(inherit)*另一个类的方法(methods),属性(property)和其它特性。当一个类继承其它类时,继承类叫*子类(subclass)*,被继承类叫*超类(或父类,superclass)*。在 Swift 中,继承是区分「类」与其它类型的一个基本特征。 -在 Swift 中,类可以调用和访问超类的方法,属性和附属脚本(subscripts),并且可以重写(override)这些方法,属性和附属脚本来优化或修改它们的行为。Swift 会检查你的重写定义在超类中是否有匹配的定义,以此确保你的重写行为是正确的。 +在 Swift 中,类可以调用和访问超类的方法,属性和下标脚本(subscripts),并且可以重写(override)这些方法,属性和下标脚本来优化或修改它们的行为。Swift 会检查你的重写定义在超类中是否有匹配的定义,以此确保你的重写行为是正确的。 可以为类中继承来的属性添加属性观察器(property observer),这样一来,当属性值改变时,类就会被通知到。可以为任何属性添加属性观察器,无论它原本被定义为存储型属性(stored property)还是计算型属性(computed property)。 @@ -139,21 +139,21 @@ println("Tandem: \(tandem.description())") ## 重写(Overriding) -子类可以为继承来的实例方法(instance method),类方法(class method),实例属性(instance property),或附属脚本(subscript)提供自己定制的实现(implementation)。我们把这种行为叫*重写(overriding)*。 +子类可以为继承来的实例方法(instance method),类方法(class method),实例属性(instance property),或下标脚本(subscript)提供自己定制的实现(implementation)。我们把这种行为叫*重写(overriding)*。 如果要重写某个特性,你需要在重写定义的前面加上`override`关键字。这么做,你就表明了你是想提供一个重写版本,而非错误地提供了一个相同的定义。意外的重写行为可能会导致不可预知的错误,任何缺少`override`关键字的重写都会在编译时被诊断为错误。 `override`关键字会提醒 Swift 编译器去检查该类的超类(或其中一个父类)是否有匹配重写版本的声明。这个检查可以确保你的重写定义是正确的。 -### 访问超类的方法,属性及附属脚本 +### 访问超类的方法,属性及下标脚本 -当你在子类中重写超类的方法,属性或附属脚本时,有时在你的重写版本中使用已经存在的超类实现会大有裨益。比如,你可以优化已有实现的行为,或在一个继承来的变量中存储一个修改过的值。 +当你在子类中重写超类的方法,属性或下标脚本时,有时在你的重写版本中使用已经存在的超类实现会大有裨益。比如,你可以优化已有实现的行为,或在一个继承来的变量中存储一个修改过的值。 -在合适的地方,你可以通过使用`super`前缀来访问超类版本的方法,属性或附属脚本: +在合适的地方,你可以通过使用`super`前缀来访问超类版本的方法,属性或下标脚本: * 在方法`someMethod`的重写实现中,可以通过`super.someMethod()`来调用超类版本的`someMethod`方法。 * 在属性`someProperty`的 getter 或 setter 的重写实现中,可以通过`super.someProperty`来访问超类版本的`someProperty`属性。 -* 在附属脚本的重写实现中,可以通过`super[someIndex]`来访问超类版本中的相同附属脚本。 +* 在下标脚本的重写实现中,可以通过`super[someIndex]`来访问超类版本中的相同下标脚本。 ### 重写方法 @@ -266,8 +266,8 @@ println("AutomaticCar: \(automatic.description())") ## 防止重写 -你可以通过把方法,属性或附属脚本标记为*`final`*来防止它们被重写,只需要在声明关键字前加上`@final`特性即可。(例如:`@final var`, `@final func`, `@final class func`, 以及 `@final subscript`) +你可以通过把方法,属性或下标脚本标记为*`final`*来防止它们被重写,只需要在声明关键字前加上`@final`特性即可。(例如:`@final var`, `@final func`, `@final class func`, 以及 `@final subscript`) -如果你重写了`final`方法,属性或附属脚本,在编译时会报错。在扩展中,你添加到类里的方法,属性或附属脚本也可以在扩展的定义里标记为 final。 +如果你重写了`final`方法,属性或下标脚本,在编译时会报错。在扩展中,你添加到类里的方法,属性或下标脚本也可以在扩展的定义里标记为 final。 你可以通过在关键字`class`前添加`@final`特性(`@final class`)来将整个类标记为 final 的,这样的类是不可被继承的,否则会报编译错误。 diff --git a/source/chapter2/14_Initialization.md b/source/chapter2/14_Initialization.md old mode 100644 new mode 100755 diff --git a/source/chapter2/15_Deinitialization.md b/source/chapter2/15_Deinitialization.md old mode 100644 new mode 100755 diff --git a/source/chapter2/16_Automatic_Reference_Counting.md b/source/chapter2/16_Automatic_Reference_Counting.md old mode 100644 new mode 100755 diff --git a/source/chapter2/17_Optional_Chaining.md b/source/chapter2/17_Optional_Chaining.md old mode 100644 new mode 100755 diff --git a/source/chapter2/18_Type_Casting.md b/source/chapter2/18_Type_Casting.md old mode 100644 new mode 100755 diff --git a/source/chapter2/19_Nested_Types.md b/source/chapter2/19_Nested_Types.md old mode 100644 new mode 100755 diff --git a/source/chapter2/20_Extensions.md b/source/chapter2/20_Extensions.md old mode 100644 new mode 100755 index 1108be7a..27269f41 --- a/source/chapter2/20_Extensions.md +++ b/source/chapter2/20_Extensions.md @@ -23,7 +23,7 @@ Swift 中的扩展可以: - 提供新的构造器 - 定义下标 - 定义和使用新的嵌套类型 -- 使一个已有类型符合某个接口 +- 使一个已有类型符合某个协议 >注意: @@ -41,7 +41,7 @@ extension SomeType { } ``` -一个扩展可以扩展一个已有类型,使其能够适配一个或多个协议(protocol)。当这种情况发生时,接口的名字应该完全按照类或结构体的名字的方式进行书写: +一个扩展可以扩展一个已有类型,使其能够适配一个或多个协议(protocol)。当这种情况发生时,协议的名字应该完全按照类或结构体的名字的方式进行书写: ``` extension SomeType: SomeProtocol, AnotherProctocol { diff --git a/source/chapter2/21_Protocols.md b/source/chapter2/21_Protocols.md old mode 100644 new mode 100755 diff --git a/source/chapter2/22_Generics.md b/source/chapter2/22_Generics.md old mode 100644 new mode 100755 diff --git a/source/chapter2/23_Advanced_Operators.md b/source/chapter2/23_Advanced_Operators.md old mode 100644 new mode 100755 diff --git a/source/chapter2/chapter2.md b/source/chapter2/chapter2.md old mode 100644 new mode 100755 diff --git a/source/chapter3/01_About_the_Language_Reference.md b/source/chapter3/01_About_the_Language_Reference.md old mode 100644 new mode 100755 diff --git a/source/chapter3/02_Lexical_Structure.md b/source/chapter3/02_Lexical_Structure.md old mode 100644 new mode 100755 diff --git a/source/chapter3/03_Types.md b/source/chapter3/03_Types.md old mode 100644 new mode 100755 diff --git a/source/chapter3/04_Expressions.md b/source/chapter3/04_Expressions.md old mode 100644 new mode 100755 index 53db2650..b23d79ea --- a/source/chapter3/04_Expressions.md +++ b/source/chapter3/04_Expressions.md @@ -607,17 +607,17 @@ someInstance.dynamicType.printClassName() > > *dynamic-type-expression* → *postfix-expression*­.­dynamicType­ -### 附属脚本表达式(Subscript Expression) +### 下标脚本表达式(Subscript Expression) -附属脚本表达式提供了通过附属脚本访问getter/setter 的方法。它的形式是: +下标脚本表达式提供了通过下标脚本访问getter/setter 的方法。它的形式是: `expression`[`index expressions`] -可以通过附属脚本表达式通过getter获取某个值,或者通过setter赋予某个值. +可以通过下标脚本表达式通过getter获取某个值,或者通过setter赋予某个值. 关于subscript的声明,请参见: Protocol Subscript Declaration. -> 附属脚本表达式的语法 +> 下标脚本表达式的语法 > > *subscript-expression* → *postfix-expression*­[­*expression-list*­]­ diff --git a/source/chapter3/05_Declarations.md b/source/chapter3/05_Declarations.md old mode 100644 new mode 100755 index e928c346..914a46da --- a/source/chapter3/05_Declarations.md +++ b/source/chapter3/05_Declarations.md @@ -21,7 +21,7 @@ - [构造器声明](#initializer_declaration) - [析构声明](#deinitializer_declaration) - [扩展声明](#extension_declaration) -- [附属脚本声明](#subscript_declaration) +- [下标脚本声明](#subscript_declaration) - [运算符声明](#operator_declaration) 一条声明可以在你的程序里引入新的名字和构造。举例来说,你可以使用声明来引入函数和方法,变量和常量,或者来定义 @@ -136,7 +136,7 @@ 3 println("The second number is \(secondNumber).") 4 // prints "The second number is 42." -类型注释(:type)在常量声明中是一个可选项,它可以用来描述在类型接口(type inference)中找到的类型。 +类型注释(:type)在常量声明中是一个可选项,它可以用来描述在类型推断(type inference)中找到的类型。 声明一个静态常量要使用关键字static。静态属性在类型属性(type propetries)中有介绍。 @@ -616,7 +616,7 @@ protocol protocol name: inherited protocols { } ``` -协议的主体包含零或多个协议成员声明,这些成员描述了任何采用该协议必须满足的一致性要求。特别的,一个协议可以声明必须实现某些属性、方法、初始化程序及附属脚本的一致性类型。协议也可以声明专用种类的类型别名,叫做关联类型,它可以指定协议的不同声明之间的关系。协议成员声明会在下面的详情里进行讨论。 +协议的主体包含零或多个协议成员声明,这些成员描述了任何采用该协议必须满足的一致性要求。特别的,一个协议可以声明必须实现某些属性、方法、初始化程序及下标脚本的一致性类型。协议也可以声明专用种类的类型别名,叫做关联类型,它可以指定协议的不同声明之间的关系。协议成员声明会在下面的详情里进行讨论。 协议类型可以从很多其它协议那继承。当一个协议类型从其它协议那继承的时候,来自其它协议的所有要求就集合了,而且从当前协议继承的任何类型必须符合所有的这些要求。对于如何使用协议继承的例子,查看[协议继承](../chapter2/21_Protocols.html#protocol_inheritance) @@ -626,7 +626,7 @@ protocol protocol name: inherited protocols { 你可以通过采用在类型的扩展声明中的协议来为之前声明的类型添加协议一致性。在扩展中你必须实现所有采用协议的要求。如果该类型已经实现了所有的要求,你可以让这个扩展声明的主题留空。 -默认地,符合某一个协议的类型必须实现所有声明在协议中的属性、方法和附属脚本。也就是说,你可以用`optional`属性标注这些协议成员声明以指定它们的一致性类型实现是可选的。`optional`属性仅仅可以用于使用`objc`属性标记过的协议。这样的结果就是仅仅类类型可以采用并符合包含可选成员要求的协议。更多关于如何使用`optional`属性的信息及如何访问可选协议成员的指导——比如当你不能肯定是否一致性的类型实现了它们——参见[可选协议要求](../chapter2/21_Protocols.html#optional_protocol_requirements) +默认地,符合某一个协议的类型必须实现所有声明在协议中的属性、方法和下标脚本。也就是说,你可以用`optional`属性标注这些协议成员声明以指定它们的一致性类型实现是可选的。`optional`属性仅仅可以用于使用`objc`属性标记过的协议。这样的结果就是仅仅类类型可以采用并符合包含可选成员要求的协议。更多关于如何使用`optional`属性的信息及如何访问可选协议成员的指导——比如当你不能肯定是否一致性的类型实现了它们——参见[可选协议要求](../chapter2/21_Protocols.html#optional_protocol_requirements) 为了限制协议的采用仅仅针对类类型,需要使用`class_protocol`属性标记整个协议声明。任意继承自标记有`class_protocol`属性协议的协议都可以智能地仅能被类类型采用。 @@ -694,18 +694,18 @@ protocol-property-declaration → variable-declaration-head­variable-name­type >protocol-initializer-declaration → initializer-head­generic-parameter-clause­opt­parameter-clause­ -###协议附属脚本声明 +###协议下标脚本声明 -协议声明了一致性类型必须在协议声明的主体里通过引入一个协议附属脚本声明来实现一个附属脚本。协议属性声明 -对附属脚本声明有一个特殊的形式: +协议声明了一致性类型必须在协议声明的主体里通过引入一个协议下标脚本声明来实现一个下标脚本。协议属性声明 +对下标脚本声明有一个特殊的形式: >subscript (parameters) -> return type { get set } -附属脚本声明只为和协议一致的类型声明了必需的最小数量的的getter和setter。如果附属脚本申明包含get和set关键字, -一致的类型也必须有一个getter和setter语句。如果附属脚本声明值包含get关键字,一致的类型必须至少包含一个 +下标脚本声明只为和协议一致的类型声明了必需的最小数量的的getter和setter。如果下标脚本申明包含get和set关键字, +一致的类型也必须有一个getter和setter语句。如果下标脚本声明值包含get关键字,一致的类型必须至少包含一个 getter语句,可以选择是否包含setter语句。 -更多参阅附属脚本声明。 +更多参阅下标脚本声明。 >GRAMMAR OF A PROTOCOL SUBSCRIPT DECLARATION @@ -754,7 +754,7 @@ getter语句,可以选择是否包含setter语句。 你可以使用requierd关键字,将便利构造器和指定构造器标记为每个子类的构造器都必须拥有的。因为指定构造器 不被子类继承,他们必须被立即执行。当子类直接执行所有超类的指定构造器(或使用便利构造器重写指定构造器)时, -必需的便利构造器可以被隐式的执行,亦可以被继承。不像方法,附属脚本那样,你不需要为这些重写的构造器标注 +必需的便利构造器可以被隐式的执行,亦可以被继承。不像方法,下标脚本那样,你不需要为这些重写的构造器标注 overrride关键字。 查看更多关于不同声明方法的构造器的例子,参阅构造过程一节。 @@ -798,7 +798,7 @@ overrride关键字。 } 一个扩展声明体包括零个或多个声明。这些声明可以包括计算型属性,计算型静态属性,实例方法,静态和类方法,构造器, -附属脚本声明,甚至其他结构体,类,和枚举声明。扩展声明不能包含析构器,协议声明,存储型属性,属性监测器或其他 +下标脚本声明,甚至其他结构体,类,和枚举声明。扩展声明不能包含析构器,协议声明,存储型属性,属性监测器或其他 的扩展属性。详细讨论和查看包含多种扩展声明的实例,参见扩展一节。 扩展声明可以向现存的类,结构体,枚举内添加一致的协议。扩展声明不能向一个类中添加继承的类,因此 @@ -815,9 +815,9 @@ type-inheritance-clause是一个只包含协议列表的扩展声明。 >extension-body → {­declarations­opt­}­ -##附属脚本声明(translated by 林) +##下标脚本声明(translated by 林) -附属脚本用于向特定类型添加附属脚本支持,通常为访问集合,列表和序列的元素时提供语法便利。附属脚本声明使用关键字`subscript`,声明形式如下: +下标脚本用于向特定类型添加下标脚本支持,通常为访问集合,列表和序列的元素时提供语法便利。下标脚本声明使用关键字`subscript`,声明形式如下: > subscript (`parameter`) -> (return type){ get{ `statements` @@ -826,19 +826,19 @@ type-inheritance-clause是一个只包含协议列表的扩展声明。 `statements` } } -附属脚本声明只能在类,结构体,枚举,扩展和协议声明的上下文进行声明。 +下标脚本声明只能在类,结构体,枚举,扩展和协议声明的上下文进行声明。 -_变量(parameters)_指定一个或多个用于在相关类型的附属脚本中访问元素的索引(例如,表达式`object[i]`中的`i`)。尽管用于元素访问的索引可以是任意类型的,但是每个变量必须包含一个用于指定每种索引类型的类型标注。_返回类型(return type)_指定被访问的元素的类型。 +_变量(parameters)_指定一个或多个用于在相关类型的下标脚本中访问元素的索引(例如,表达式`object[i]`中的`i`)。尽管用于元素访问的索引可以是任意类型的,但是每个变量必须包含一个用于指定每种索引类型的类型标注。_返回类型(return type)_指定被访问的元素的类型。 -和计算性属性一样,附属脚本声明支持对访问元素的读写操作。getter用于读取值,setter用于写入值。setter子句是可选的,当仅需要一个getter子句时,可以将二者都忽略且直接返回请求的值即可。也就是说,如果使用了setter子句,就必须使用getter子句。 +和计算性属性一样,下标脚本声明支持对访问元素的读写操作。getter用于读取值,setter用于写入值。setter子句是可选的,当仅需要一个getter子句时,可以将二者都忽略且直接返回请求的值即可。也就是说,如果使用了setter子句,就必须使用getter子句。 setter的名字和封闭的括号是可选的。如果使用了setter名称,它会被当做传给setter的变量的名称。如果不使用setter名称,那么传给setter的变量的名称默认是`value`。setter名称的类型必须与_返回类型(return type)_的类型相同。 -可以在附属脚本声明的类型中,可以重载附属脚本,只要_变量(parameters)_或_返回类型(return type)_与先前的不同即可。此时,必须使用`override`关键字声明那个被覆盖的附属脚本。(注:好乱啊!到底是重载还是覆盖?!) +可以在下标脚本声明的类型中,可以重载下标脚本,只要_变量(parameters)_或_返回类型(return type)_与先前的不同即可。此时,必须使用`override`关键字声明那个被覆盖的下标脚本。(注:好乱啊!到底是重载还是覆盖?!) -同样可以在协议声明的上下文中声明附属脚本,[Protocol Subscript Declaration](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-XID_619)中有所描述。 +同样可以在协议声明的上下文中声明下标脚本,[Protocol Subscript Declaration](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-XID_619)中有所描述。 -更多关于附属脚本和附属脚本声明的例子,请参考[Subscripts](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Subscripts.html#//apple_ref/doc/uid/TP40014097-CH16-XID_393)。 +更多关于下标脚本和下标脚本声明的例子,请参考[Subscripts](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Subscripts.html#//apple_ref/doc/uid/TP40014097-CH16-XID_393)。 >GRAMMAR OF A SUBSCRIPT DECLARATION diff --git a/source/chapter3/06_Attributes.md b/source/chapter3/06_Attributes.md old mode 100644 new mode 100755 diff --git a/source/chapter3/07_Patterns.md b/source/chapter3/07_Patterns.md old mode 100644 new mode 100755 diff --git a/source/chapter3/08_Generic_Parameters_and_Arguments.md b/source/chapter3/08_Generic_Parameters_and_Arguments.md old mode 100644 new mode 100755 diff --git a/source/chapter3/09_Summary_of_the_Grammar.md b/source/chapter3/09_Summary_of_the_Grammar.md old mode 100644 new mode 100755 index 87d5c488..6d560a2c --- a/source/chapter3/09_Summary_of_the_Grammar.md +++ b/source/chapter3/09_Summary_of_the_Grammar.md @@ -159,7 +159,7 @@ _________________ > *声明* → [*构造器声明*](..\chapter3\05_Declarations.html#initializer_declaration) > *声明* → [*析构器声明*](..\chapter3\05_Declarations.html#deinitializer_declaration) > *声明* → [*扩展声明*](..\chapter3\05_Declarations.html#extension_declaration) -> *声明* → [*附属脚本声明*](..\chapter3\05_Declarations.html#subscript_declaration) +> *声明* → [*下标脚本声明*](..\chapter3\05_Declarations.html#subscript_declaration) > *声明* → [*运算符声明*](..\chapter3\05_Declarations.html#operator_declaration) > *声明(Declarations)列表* → [*声明*](..\chapter3\05_Declarations.html#declaration) [*声明(Declarations)列表*](..\chapter3\05_Declarations.html#declarations) _可选_ > *声明描述符(Specifiers)列表* → [*声明描述符(Specifier)*](..\chapter3\05_Declarations.html#declaration_specifier) [*声明描述符(Specifiers)列表*](..\chapter3\05_Declarations.html#declaration_specifiers) _可选_ @@ -285,7 +285,7 @@ _________________ > *协议成员声明* → [*协议属性声明*](..\chapter3\05_Declarations.html#protocol_property_declaration) > *协议成员声明* → [*协议方法声明*](..\chapter3\05_Declarations.html#protocol_method_declaration) > *协议成员声明* → [*协议构造器声明*](..\chapter3\05_Declarations.html#protocol_initializer_declaration) -> *协议成员声明* → [*协议附属脚本声明*](..\chapter3\05_Declarations.html#protocol_subscript_declaration) +> *协议成员声明* → [*协议下标脚本声明*](..\chapter3\05_Declarations.html#protocol_subscript_declaration) > *协议成员声明* → [*协议关联类型声明*](..\chapter3\05_Declarations.html#protocol_associated_type_declaration) > *协议成员声明(Declarations)列表* → [*协议成员声明*](..\chapter3\05_Declarations.html#protocol_member_declaration) [*协议成员声明(Declarations)列表*](..\chapter3\05_Declarations.html#protocol_member_declarations) _可选_ @@ -306,8 +306,8 @@ _________________

-> 协议附属脚本声明语法 -> *协议附属脚本声明* → [*附属脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*附属脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter关键字(Keyword)块*](..\chapter3\05_Declarations.html#getter_setter_keyword_block) +> 协议下标脚本声明语法 +> *协议下标脚本声明* → [*下标脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*下标脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter关键字(Keyword)块*](..\chapter3\05_Declarations.html#getter_setter_keyword_block)

@@ -334,12 +334,12 @@ _________________

-> 附属脚本声明语法 -> *附属脚本声明* → [*附属脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*附属脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*代码块*](..\chapter3\05_Declarations.html#code_block) -> *附属脚本声明* → [*附属脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*附属脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter块*](..\chapter3\05_Declarations.html#getter_setter_block) -> *附属脚本声明* → [*附属脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*附属脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter关键字(Keyword)块*](..\chapter3\05_Declarations.html#getter_setter_keyword_block) -> *附属脚本头(Head)* → [*特性(Attributes)列表*](..\chapter3\06_Attributes.html#attributes) _可选_ **subscript** [*参数子句*](..\chapter3\05_Declarations.html#parameter_clause) -> *附属脚本结果(Result)* → **->** [*特性(Attributes)列表*](..\chapter3\06_Attributes.html#attributes) _可选_ [*类型*](..\chapter3\03_Types.html#type) +> 下标脚本声明语法 +> *下标脚本声明* → [*下标脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*下标脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*代码块*](..\chapter3\05_Declarations.html#code_block) +> *下标脚本声明* → [*下标脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*下标脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter块*](..\chapter3\05_Declarations.html#getter_setter_block) +> *下标脚本声明* → [*下标脚本头(Head)*](..\chapter3\05_Declarations.html#subscript_head) [*下标脚本结果(Result)*](..\chapter3\05_Declarations.html#subscript_result) [*getter-setter关键字(Keyword)块*](..\chapter3\05_Declarations.html#getter_setter_keyword_block) +> *下标脚本头(Head)* → [*特性(Attributes)列表*](..\chapter3\06_Attributes.html#attributes) _可选_ **subscript** [*参数子句*](..\chapter3\05_Declarations.html#parameter_clause) +> *下标脚本结果(Result)* → **->** [*特性(Attributes)列表*](..\chapter3\06_Attributes.html#attributes) _可选_ [*类型*](..\chapter3\03_Types.html#type)

diff --git a/source/chapter3/10_Statements.md b/source/chapter3/10_Statements.md old mode 100644 new mode 100755 diff --git a/source/chapter3/chapter3.md b/source/chapter3/chapter3.md old mode 100644 new mode 100755 From a516af6a531a104ec88da0d236ecf389a5ec72af Mon Sep 17 00:00:00 2001 From: wuxing Date: Sat, 14 Jun 2014 17:25:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=20=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter1/01_swift.md | 2 +- source/chapter2/03_Strings_and_Characters.md | 4 ++-- source/chapter2/07_Closures.md | 2 +- source/chapter2/10_Properties.md | 6 +++--- source/chapter2/11_Methods.md | 4 ++-- .../16_Automatic_Reference_Counting.md | 6 +++--- source/chapter2/17_Optional_Chaining.md | 4 ++-- source/chapter2/21_Protocols.md | 2 +- source/chapter2/22_Generics.md | 14 ++++++------- source/chapter2/23_Advanced_Operators.md | 4 ++-- source/chapter3/05_Declarations.md | 20 +++++++++---------- source/chapter3/07_Patterns.md | 4 ++-- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/source/chapter1/01_swift.md b/source/chapter1/01_swift.md index ead740fe..ca1004ed 100755 --- a/source/chapter1/01_swift.md +++ b/source/chapter1/01_swift.md @@ -5,7 +5,7 @@ # 关于 Swift ----------------- -Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用。Swift 结合了 C 和 Objective-C 的优点并且不受 C 兼容性的限制。Swift 采用安全的编程模式并添加了很多新特性,这将使编程更简单,更灵活,也更有趣。Swift 是基于成熟而且倍受喜爱的 Cocoa 和 Cocoa Touch 框架,他的降临将重新定义软件开发。 +Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用。Swift 结合了 C 和 Objective-C 的优点并且不受 C 兼容性的限制。Swift 采用安全的编程模式并添加了很多新特性,这将使编程更简单,更灵活,也更有趣。Swift 是基于成熟而且倍受喜爱的 Cocoa 和 Cocoa Touch 框架,它的降临将重新定义软件开发。 Swift 的开发从很久之前就开始了。为了给 Swift 打好基础,苹果公司改进了编译器,调试器和框架结构。我们使用自动引用计数(Automatic Reference Counting, ARC)来简化内存管理。我们在 Foundation 和 Cocoa 的基础上构建框架栈并将其标准化。Objective-C 本身支持块、集合语法和模块,所以框架可以轻松支持现代编程语言技术。正是得益于这些基础工作,我们现在才能发布这样一个用于未来苹果软件开发的新语言。 diff --git a/source/chapter2/03_Strings_and_Characters.md b/source/chapter2/03_Strings_and_Characters.md index 0e3e5bdc..5004e22d 100755 --- a/source/chapter2/03_Strings_and_Characters.md +++ b/source/chapter2/03_Strings_and_Characters.md @@ -364,7 +364,7 @@ print("\n") // 68 111 103 33 240 159 144 182 ``` -上面的例子中,前四个10进制代码单元值 (68, 111, 103, 33) 代表了字符`D` `o` `g`和`!`,他们的 UTF-8 表示与 ASCII 表示相同。 +上面的例子中,前四个10进制代码单元值 (68, 111, 103, 33) 代表了字符`D` `o` `g`和`!`,它们的 UTF-8 表示与 ASCII 表示相同。 后四个代码单元值 (240, 159, 144, 182) 是`DOG FACE`的4字节 UTF-8 表示。 @@ -381,7 +381,7 @@ print("\n") // 68 111 103 33 55357 56374 ``` -同样,前四个代码单元值 (68, 111, 103, 33) 代表了字符`D` `o` `g`和`!`,他们的 UTF-16 代码单元和 UTF-8 完全相同。 +同样,前四个代码单元值 (68, 111, 103, 33) 代表了字符`D` `o` `g`和`!`,它们的 UTF-16 代码单元和 UTF-8 完全相同。 第五和第六个代码单元值 (55357 和 56374) 是`DOG FACE`字符的UTF-16 表示。 第一个值为`U+D83D`(十进制值为 55357),第二个值为`U+DC36`(十进制值为 56374)。 diff --git a/source/chapter2/07_Closures.md b/source/chapter2/07_Closures.md index 814d6277..309d0b2c 100755 --- a/source/chapter2/07_Closures.md +++ b/source/chapter2/07_Closures.md @@ -227,7 +227,7 @@ let digitNames = [ let numbers = [16, 58, 510] ``` -如上代码创建了一个数字位和他们名字映射的英文版本字典。 +如上代码创建了一个数字位和它们名字映射的英文版本字典。 同时定义了一个准备转换为字符串的整型数组。 您现在可以通过传递一个尾随闭包给`numbers`的`map`方法来创建对应的字符串版本数组。 diff --git a/source/chapter2/10_Properties.md b/source/chapter2/10_Properties.md index 7dbeb082..3c8c8a38 100755 --- a/source/chapter2/10_Properties.md +++ b/source/chapter2/10_Properties.md @@ -27,7 +27,7 @@ 可以在定义存储属性的时候指定默认值,请参考[构造过程](../chapter2/14_Initialization.html)一章的[默认属性值](../chapter2/14_Initialization.html#default_property_values)一节。也可以在构造过程中设置或修改存储属性的值,甚至修改常量存储属性的值,请参考[构造过程](../chapter2/14_Initialization.html)一章的[在初始化阶段修改常量存储属性](../chapter2/14_Initialization.html#modifying_constant_properties_during_initialization)一节。 -下面的例子定义了一个名为`FixedLengthRange`的结构体,他描述了一个在创建后无法修改值域宽度的区间: +下面的例子定义了一个名为`FixedLengthRange`的结构体,它描述了一个在创建后无法修改值域宽度的区间: ``` struct FixedLengthRange { @@ -202,7 +202,7 @@ struct AlternativeRect { > 注意: > -> 必须使用`var`关键字定义计算属性,包括只读计算属性,因为他们的值不是固定的。`let`关键字只用来声明常量属性,表示初始化后再也无法修改的值。 +> 必须使用`var`关键字定义计算属性,包括只读计算属性,因为它们的值不是固定的。`let`关键字只用来声明常量属性,表示初始化后再也无法修改的值。 只读计算属性的声明可以去掉`get`关键字和花括号: @@ -243,7 +243,7 @@ println("the volume of fourByFiveByTwo is \(fourByFiveByTwo.volume)") > 注意: > -> `willSet`和`didSet`监视器在属性初始化过程中不会被调用,他们只会当属性的值在初始化之外的地方被设置时被调用。 +> `willSet`和`didSet`监视器在属性初始化过程中不会被调用,它们只会当属性的值在初始化之外的地方被设置时被调用。 这里是一个`willSet`和`didSet`的实际例子,其中定义了一个名为`StepCounter`的类,用来统计当人步行时的总步数,可以跟计步器或其他日常锻炼的统计装置的输入数据配合使用。 diff --git a/source/chapter2/11_Methods.md b/source/chapter2/11_Methods.md index 6ddeb02c..93503dbd 100755 --- a/source/chapter2/11_Methods.md +++ b/source/chapter2/11_Methods.md @@ -285,7 +285,7 @@ class Player { } ``` -`Player`类创建一个新的`LevelTracker`实例来监测这个用户的发展进度。他提供了`completedLevel`方法:一旦玩家完成某个指定等级就调用它。这个方法为所有玩家解锁下一等级,并且将当前玩家的进度更新为下一等级。(我们忽略了`advanceToLevel`返回的布尔值,因为之前调用`LevelTracker.unlockLevel`时就知道了这个等级已经被解锁了)。 +`Player`类创建一个新的`LevelTracker`实例来监测这个用户的发展进度。它提供了`completedLevel`方法:一旦玩家完成某个指定等级就调用它。这个方法为所有玩家解锁下一等级,并且将当前玩家的进度更新为下一等级。(我们忽略了`advanceToLevel`返回的布尔值,因为之前调用`LevelTracker.unlockLevel`时就知道了这个等级已经被解锁了)。 你还可以为一个新的玩家创建一个`Player`的实例,然后看这个玩家完成等级一时发生了什么: @@ -297,7 +297,7 @@ println("highest unlocked level is now \(LevelTracker.highestUnlockedLevel)") ) ``` -如果你创建了第二个玩家,并尝试让他开始一个没有被任何玩家解锁的等级,那么这次设置玩家当前等级的尝试将会失败: +如果你创建了第二个玩家,并尝试让它开始一个没有被任何玩家解锁的等级,那么这次设置玩家当前等级的尝试将会失败: ``` player = Player(name: "Beto") diff --git a/source/chapter2/16_Automatic_Reference_Counting.md b/source/chapter2/16_Automatic_Reference_Counting.md index 30522b37..d25ba98c 100755 --- a/source/chapter2/16_Automatic_Reference_Counting.md +++ b/source/chapter2/16_Automatic_Reference_Counting.md @@ -274,7 +274,7 @@ Swift 提供了两种办法用来解决你在使用类的属性时所遇到的 john = Customer(name: "John Appleseed") john!.card = CreditCard(number: 1234_5678_9012_3456, customer: john!) -在你关联两个实例后,他们的引用关系如下图所示: +在你关联两个实例后,它们的引用关系如下图所示: ![](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Art/unownedReference01_2x.png) @@ -329,7 +329,7 @@ Swift 提供了两种办法用来解决你在使用类的属性时所遇到的 `Country`的构造函数调用了`City`的构造函数。然而,只有`Country`的实例完全初始化完后,`Country`的构造函数才能把`self`传给`City`的构造函数。([在两段式构造过程中有具体描述](14_Initialization.html)) -为了满足这种需求,通过在类型结尾处加上感叹号(City!)的方式,将`Country`的`capitalCity`属性声明为隐式解析可选类型的属性。这表示像其他可选类型一样,`capitalCity`属性的默认值为`nil`,但是不需要展开他的值就能访问它。([在隐式解析可选类型中有描述](01_The_Basics.html)) +为了满足这种需求,通过在类型结尾处加上感叹号(City!)的方式,将`Country`的`capitalCity`属性声明为隐式解析可选类型的属性。这表示像其他可选类型一样,`capitalCity`属性的默认值为`nil`,但是不需要展开它的值就能访问它。([在隐式解析可选类型中有描述](01_The_Basics.html)) 由于`capitalCity`默认值为`nil`,一旦`Country`的实例在构造函数中给`name`属性赋值后,整个初始化过程就完成了。这代表一旦`name`属性被赋值后,`Country`的构造函数就能引用并传递隐式的`self`。`Country`的构造函数在赋值`capitalCity`时,就能将`self`作为参数传递给`City`的构造函数。 @@ -449,7 +449,7 @@ Swift 有如下要求:只要在闭包内使用`self`的成员,就要用`self 当闭包和捕获的实例总是互相引用时并且总是同时销毁时,将闭包内的捕获定义为无主引用。 -相反的,当捕获引用有时可能会是`nil`时,将闭包内的捕获定义为弱引用。弱引用总是可选类型,并且当引用的实例被销毁后,弱引用的值会自动置为`nil`。这使我们可以在闭包内检查他们是否存在。 +相反的,当捕获引用有时可能会是`nil`时,将闭包内的捕获定义为弱引用。弱引用总是可选类型,并且当引用的实例被销毁后,弱引用的值会自动置为`nil`。这使我们可以在闭包内检查它们是否存在。 >注意: > diff --git a/source/chapter2/17_Optional_Chaining.md b/source/chapter2/17_Optional_Chaining.md index f10020dd..a92c94dc 100755 --- a/source/chapter2/17_Optional_Chaining.md +++ b/source/chapter2/17_Optional_Chaining.md @@ -24,7 +24,7 @@ Swift 的可选链和 Objective-C 中的消息为空有些相像,但是 Swift ## 可选链可替代强制解析 -通过在想调用的属性、方法、或子脚本的可选值(`optional value`)(非空)后面放一个问号,可以定义一个可选链。这一点很像在可选值后面放一个叹号来强制拆得其封包内的值。他们的主要的区别在于当可选值为空时可选链即刻失败,然而一般的强制解析将会引发运行时错误。 +通过在想调用的属性、方法、或子脚本的可选值(`optional value`)(非空)后面放一个问号,可以定义一个可选链。这一点很像在可选值后面放一个叹号来强制拆得其封包内的值。它们的主要的区别在于当可选值为空时可选链即刻失败,然而一般的强制解析将会引发运行时错误。 为了反映可选链可以调用空(`nil`),不论你调用的属性、方法、子脚本等返回的值是不是可选值,它的返回结果都是一个可选值。你可以利用这个返回值来检测你的可选链是否调用成功,有返回值即成功,返回nil则失败。 @@ -232,7 +232,7 @@ Swift 的可选链和 Objective-C 中的消息为空有些相像,但是 Swift 如果你试图通过可选链获得`Int`值,不论使用了多少层链接返回的总是`Int?`。 相似的,如果你试图通过可选链获得`Int?`值,不论使用了多少层链接返回的总是`Int?`。 -下面的例子试图获取`john`的`residence`属性里的`address`的`street`属性。这里使用了两层可选链来联系`residence`和`address`属性,他们两者都是可选类型: +下面的例子试图获取`john`的`residence`属性里的`address`的`street`属性。这里使用了两层可选链来联系`residence`和`address`属性,它们两者都是可选类型: if let johnsStreet = john.residence?.address?.street { println("John's street name is \(johnsStreet).") diff --git a/source/chapter2/21_Protocols.md b/source/chapter2/21_Protocols.md index c8c4997d..d6431a4f 100755 --- a/source/chapter2/21_Protocols.md +++ b/source/chapter2/21_Protocols.md @@ -525,7 +525,7 @@ init(legs: Int) { self.legs = legs } } -`Circle,Country,Animal`并没有一个相同的基类,所以采用`AnyObject`类型的数组来装载在他们的实例,如下所示: +`Circle,Country,Animal`并没有一个相同的基类,所以采用`AnyObject`类型的数组来装载在它们的实例,如下所示: let objects: AnyObject[] = [ Circle(radius: 2.0), diff --git a/source/chapter2/22_Generics.md b/source/chapter2/22_Generics.md index e2be186a..89708899 100755 --- a/source/chapter2/22_Generics.md +++ b/source/chapter2/22_Generics.md @@ -155,7 +155,7 @@ } } -这个结构体在栈中使用一个`Array`性质的`items`存储值。`Stack`提供两个方法:`push`和`pop`,从栈中压进一个值和移除一个值。这些方法标记为可变的,因为他们需要修改(或*转换*)结构体的`items`数组。 +这个结构体在栈中使用一个`Array`性质的`items`存储值。`Stack`提供两个方法:`push`和`pop`,从栈中压进一个值和移除一个值。这些方法标记为可变的,因为它们需要修改(或*转换*)结构体的`items`数组。 上面所展现的`IntStack`类型只能用于`Int`值,不过,其对于定义一个泛型`Stack`类(可以处理*任何*类型值的栈)是非常有用的。 @@ -213,7 +213,7 @@ 这个需求强制加上一个类型约束作用于`Dictionary`的键上,当然其键类型必须遵循`Hashable`协议(Swift 标准库中定义的一个特定协议)。所有的 Swift 基本类型(如`String`,`Int`, `Double`和 `Bool`)默认都是可哈希。 -当你创建自定义泛型类型时,你可以定义你自己的类型约束,当然,这些约束要支持泛型编程的强力特征中的多数。抽象概念如`可哈希`具有的类型特征是根据他们概念特征来界定的,而不是他们的直接类型特征。 +当你创建自定义泛型类型时,你可以定义你自己的类型约束,当然,这些约束要支持泛型编程的强力特征中的多数。抽象概念如`可哈希`具有的类型特征是根据它们概念特征来界定的,而不是它们的直接类型特征。 ### 类型约束语法 @@ -391,7 +391,7 @@ Swift的`Array`已经提供`append`方法,一个`count`属性和通过下标 下面的列子定义了一个名为`allItemsMatch`的泛型函数,用来检查是否两个`Container`单例包含具有相同顺序的相同元素。如果匹配到所有的元素,那么返回一个为`true`的`Boolean`值,反之,则相反。 -这两个容器可以被检查出是否是相同类型的容器(虽然它们可以是),但他们确实拥有相同类型的元素。这个需求通过一个类型约束和`where`语句结合来表示: +这两个容器可以被检查出是否是相同类型的容器(虽然它们可以是),但它们确实拥有相同类型的元素。这个需求通过一个类型约束和`where`语句结合来表示: func allItemsMatch< C1: Container, C2: Container @@ -434,11 +434,11 @@ Swift的`Array`已经提供`append`方法,一个`count`属性和通过下标 `someContainer`和`anotherContainer`包含相同的元素类型。 `someContainer`中的元素可以通过不等于操作(`!=`)来检查它们是否彼此不同。 -第三个和第四个要求结合起来的意思是`anotherContainer`中的元素也可以通过 `!=` 操作来检查,因为他们在`someContainer`中元素确实是相同的类型。 +第三个和第四个要求结合起来的意思是`anotherContainer`中的元素也可以通过 `!=` 操作来检查,因为它们在`someContainer`中元素确实是相同的类型。 -这些要求能够使`allItemsMatch`函数比较两个容器,即便他们是不同的容器类型。 +这些要求能够使`allItemsMatch`函数比较两个容器,即便它们是不同的容器类型。 -`allItemsMatch`首先检查两个容器是否拥有同样数目的items,如果他们的元素数目不同,没有办法进行匹配,函数就会`false`。 +`allItemsMatch`首先检查两个容器是否拥有同样数目的items,如果它们的元素数目不同,没有办法进行匹配,函数就会`false`。 检查完之后,函数通过`for-in`循环和半闭区间操作(..)来迭代`someContainer`中的所有元素。对于每个元素,函数检查是否`someContainer`中的元素不等于对应的`anotherContainer`中的元素,如果这两个元素不等,则这两个容器不匹配,返回`false`。 @@ -460,7 +460,7 @@ Swift的`Array`已经提供`append`方法,一个`count`属性和通过下标 } // 输出 "All items match." - 上面的例子创建一个`Stack`单例来存储`String`,然后压了三个字符串进栈。这个例子也创建了一个`Array`单例,并初始化包含三个同栈里一样的原始字符串。即便栈和数组否是不同的类型,但他们都遵循`Container`协议,而且他们都包含同样的类型值。你因此可以调用`allItemsMatch`函数,用这两个容器作为它的参数。在上面的例子中,`allItemsMatch`函数正确的显示了所有的这两个容器的`items`匹配。 + 上面的例子创建一个`Stack`单例来存储`String`,然后压了三个字符串进栈。这个例子也创建了一个`Array`单例,并初始化包含三个同栈里一样的原始字符串。即便栈和数组否是不同的类型,但它们都遵循`Container`协议,而且它们都包含同样的类型值。你因此可以调用`allItemsMatch`函数,用这两个容器作为它的参数。在上面的例子中,`allItemsMatch`函数正确的显示了所有的这两个容器的`items`匹配。 [1]: ../chapter2/06_Functions.html [2]: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Art/stackPushPop_2x.png diff --git a/source/chapter2/23_Advanced_Operators.md b/source/chapter2/23_Advanced_Operators.md index 7912d18c..2a978376 100755 --- a/source/chapter2/23_Advanced_Operators.md +++ b/source/chapter2/23_Advanced_Operators.md @@ -426,7 +426,7 @@ Swift无所知道自定义类型是否相等或不等,因为等于或者不等 } ``` -上述代码实现了相等运算符`==`来判断两个`Vector2D`对象是否有相等的值,相等的概念就是他们有相同的`x`值和相同的`y`值,我们就用这个逻辑来实现。接着使用`==`的结果实现了不相等运算符`!=`。 +上述代码实现了相等运算符`==`来判断两个`Vector2D`对象是否有相等的值,相等的概念就是它们有相同的`x`值和相同的`y`值,我们就用这个逻辑来实现。接着使用`==`的结果实现了不相等运算符`!=`。 现在我们可以使用这两个运算符来判断两个`Vector2D`对象是否相等。 @@ -489,4 +489,4 @@ let plusMinusVector = firstVector +- secondVector // plusMinusVector 此时的值为 (4.0, -2.0) ``` -这个运算符把两个向量的`x`相加,把向量的`y`相减。因为他实际是属于加减运算,所以让它保持了和加法一样的结合性和优先级(`left`和`140`)。查阅完整的Swift默认结合性和优先级的设置,请移步[表达式](../chapter3/04_Expressions.html); +这个运算符把两个向量的`x`相加,把向量的`y`相减。因为它实际是属于加减运算,所以让它保持了和加法一样的结合性和优先级(`left`和`140`)。查阅完整的Swift默认结合性和优先级的设置,请移步[表达式](../chapter3/04_Expressions.html); diff --git a/source/chapter3/05_Declarations.md b/source/chapter3/05_Declarations.md index 914a46da..ddc3a527 100755 --- a/source/chapter3/05_Declarations.md +++ b/source/chapter3/05_Declarations.md @@ -28,7 +28,7 @@ 新的命名好的枚举,结构,类和协议类型。你也可以使用一条声明来延长一个已经存在的命名好的类型的行为。或者在你的 程序里引入在其他地方声明的符号。 -在swift中,大多数声明在某种意义上讲也是执行或同事声明它们的初始化定义。这意味着,因为协议和他们的成员不匹配, +在swift中,大多数声明在某种意义上讲也是执行或同事声明它们的初始化定义。这意味着,因为协议和它们的成员不匹配, 大多数协议成员需要单独的声明。为了方便起见,也因为这些区别在swift里不是很重要,声明语句同时包含了声明和定义。 >GRAMMAR OF A DECLARATION @@ -71,7 +71,7 @@ ##模块范围 模块范围定义了对模块中其他源文件可见的代码。(注:待改进)在swift的源文件中,最高级别的代码由零个或多个语句, -声明和表达组成。变量,常量和其他的声明语句在一个源文件的最顶级被声明,使得他们对同一模块中的每个源文件都是可见的。 +声明和表达组成。变量,常量和其他的声明语句在一个源文件的最顶级被声明,使得它们对同一模块中的每个源文件都是可见的。 >GRAMMAR OF A TOP-LEVEL DECLARATION @@ -122,7 +122,7 @@ 当常量的值被给定后,常量就将常量名称和表达式初始值不变的结合在了一起,而且不能更改。 这意味着如果常量以类的形式被初始化,类本身的内容是可以改变的,但是常量和类之间的结合关系是不能改变的。 -当一个常量被声明为全局变量,它必须被给定一个初始值。当一个常量在类或者结构体中被声明时,他被认为是一个常量 +当一个常量被声明为全局变量,它必须被给定一个初始值。当一个常量在类或者结构体中被声明时,它被认为是一个常量 属性。常量并不是可计算的属性,因此不包含getters和setters。(译者注:getters和setters不知道怎么翻译,待改进) 如果常量名是一个元祖形式,元祖中的每一项初始化表达式中都要有对应的值 @@ -168,7 +168,7 @@ var variable name: type = expression 你可以在全局,函数内,或者在类和结构体的声明(context)中使用这种形式来声明一个变量。当变量以这种形式 -在全局或者一个函数内被声明时,它代表一个存储型变量。当他在类或者结构体中被声明时,他代表一个存储型变量属性。 +在全局或者一个函数内被声明时,它代表一个存储型变量。当它在类或者结构体中被声明时,它代表一个存储型变量属性。 构造器表达式可以被 @@ -190,8 +190,8 @@ } 你可以在全局,函数体内或者类,结构体,枚举,扩展声明的上下文中使用这种形式的声明。 -当变量以这种形式在全局或者一个函数内被声明时,它代表一个计算型变量。当他在类,结构体,枚举,扩展声明的上下文 -中中被声明时,他代表一个计算型变量属性。 +当变量以这种形式在全局或者一个函数内被声明时,它代表一个计算型变量。当它在类,结构体,枚举,扩展声明的上下文 +中中被声明时,它代表一个计算型变量属性。 getter用来读取变量值,setter用来写入变量值。setter子句是可选择的,只有getter是必需的,你可以将这些语句 都省略,只是简单的直接返回请求值,正如在只读计算属性(read-only computed properites)中描述的那样。 @@ -219,7 +219,7 @@ setter的初始名为newValue,正如在seter声明速记(shorthand setter decl 你可以在全局,函数体内或者类,结构体,枚举,扩展声明的上下文中使用这种形式的声明。 当变量以这种形式在全局或者一个函数内被声明时,监视器代表一个存储型变量监视器; -当他在类,结构体,枚举,扩展声明的上下文中被声明时,监视器代表属性监视器。 +当它在类,结构体,枚举,扩展声明的上下文中被声明时,监视器代表属性监视器。 你可以为适合的监视器添加任何存储型属性。你也可以通过重写子类属性的方式为适合的监视器添加任何继承的属性 (无论是存储型还是计算型的),参见重写属性监视器(overriding properyt observers)。 @@ -228,7 +228,7 @@ setter的初始名为newValue,正如在seter声明速记(shorthand setter decl 所有包含监视器的变量声明都必须有类型注释(type annotation)。 当变量或属性的值被改变时,willset和didset监视器提供了一个监视方法(适当的回应)。 -监视器不会在变量或属性第一次初始化时不会被运行,他们只有在值被外部初始化语句改变时才会被运行。 +监视器不会在变量或属性第一次初始化时不会被运行,它们只有在值被外部初始化语句改变时才会被运行。 willset监视器只有在变量或属性值被改变之前运行。新的值作为一个常量经过过willset监视器,因此不可以在 willset语句中改变它。didset监视器在变量或属性值被改变后立即运行。和willset监视器相反,为了以防止你仍然 @@ -670,7 +670,7 @@ protocol-property-declaration → variable-declaration-head­variable-name­type ###协议方法声明 协议声明了一致性类型必须在协议声明的主体里通过引入一个协议方法声明来实现一个方法. -协议方法声明和函数方法声明有着相同的形式,包含如下两条规则:他们不包括函数体,你不能在类的声明内为他们的 +协议方法声明和函数方法声明有着相同的形式,包含如下两条规则:它们不包括函数体,你不能在类的声明内为它们的 参数提供初始值.举例来说,符合的类型执行协议必需的方法。参见必需方法一节。 使用关键字class可以在协议声明中声明一个类或必需的静态方法。执行这些方法的类也用关键字class声明。 @@ -753,7 +753,7 @@ getter语句,可以选择是否包含setter语句。 以一个将所有类属性完全初始化的指定构造器的调用作为结束。便利构造器不能调用超类的构造器。 你可以使用requierd关键字,将便利构造器和指定构造器标记为每个子类的构造器都必须拥有的。因为指定构造器 -不被子类继承,他们必须被立即执行。当子类直接执行所有超类的指定构造器(或使用便利构造器重写指定构造器)时, +不被子类继承,它们必须被立即执行。当子类直接执行所有超类的指定构造器(或使用便利构造器重写指定构造器)时, 必需的便利构造器可以被隐式的执行,亦可以被继承。不像方法,下标脚本那样,你不需要为这些重写的构造器标注 overrride关键字。 diff --git a/source/chapter3/07_Patterns.md b/source/chapter3/07_Patterns.md index ae6263ac..97b04efc 100755 --- a/source/chapter3/07_Patterns.md +++ b/source/chapter3/07_Patterns.md @@ -17,7 +17,7 @@ 模式(pattern)代表了单个值或者复合值的结构。例如,元组`(1, 2)`的结构是逗号分隔的,包含两个元素的列表。因为模式代表一种值的结构,而不是特定的某个值,你可以把模式和各种同类型的值匹配起来。比如,`(x, y)`可以匹配元组`(1, 2)`,以及任何含两个元素的元组。除了将模式与一个值匹配外,你可以从合成值中提取出部分或全部,然后分别把各个部分和一个常量或变量绑定起来。 -在Swift中,模式出现在变量和常量的声明(在它们的左侧),`for-in`语句和`switch`语句(在他们的case标签)中。尽管任何模式都可以出现在`switch`语句的case标签中,但在其他情况下,只有通配符模式(wildcard pattern),标识符模式(identifier pattern)和包含这两种模式的模式才能出现。 +在Swift中,模式出现在变量和常量的声明(在它们的左侧),`for-in`语句和`switch`语句(在它们的case标签)中。尽管任何模式都可以出现在`switch`语句的case标签中,但在其他情况下,只有通配符模式(wildcard pattern),标识符模式(identifier pattern)和包含这两种模式的模式才能出现。 你可以为通配符模式(wildcard pattern),标识符模式(identifier pattern)和元组模式(tuple pattern)指定类型注释,用来限制这种模式只匹配某种类型的值。 @@ -134,7 +134,7 @@ is type pattern as type -`is`模式匹配一个值,如果这个值的类型在运行时(runtime)和`is`模式右边的指定类型(或者那个类型的子类)是一致的。`is`模式和`is`操作符一样,他们都进行类型转换,但是抛弃了返回的类型。 +`is`模式匹配一个值,如果这个值的类型在运行时(runtime)和`is`模式右边的指定类型(或者那个类型的子类)是一致的。`is`模式和`is`操作符一样,它们都进行类型转换,但是抛弃了返回的类型。 `as`模式匹配一个值,如果这个值的类型在运行时(runtime)和`as`模式右边的指定类型(或者那个类型的子类)是一致的。一旦匹配成功,匹配的值的类型被转换成`as`模式左边指定的模式。