From 9bc2388eb2787597459afa0cbf4ce2fa62377d7c Mon Sep 17 00:00:00 2001 From: futantan Date: Fri, 3 Jul 2015 10:47:56 +0800 Subject: [PATCH] =?UTF-8?q?Protocols=20-=20=E5=AE=8C=E6=88=90Protocol=20Sy?= =?UTF-8?q?ntax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter2/22_Protocols.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/chapter2/22_Protocols.md b/source/chapter2/22_Protocols.md index c8cdb814..e489cbe4 100644 --- a/source/chapter2/22_Protocols.md +++ b/source/chapter2/22_Protocols.md @@ -29,7 +29,7 @@ ## 协议的语法 -`协议`的定义方式与`类,结构体,枚举`的定义都非常相似,如下所示: +协议的定义方式与类,结构体,枚举的定义非常相似: ```swift protocol SomeProtocol { @@ -37,7 +37,7 @@ protocol SomeProtocol { } ``` -在类型名称后加上`协议名称`,中间以冒号`:`分隔即可实现协议;实现多个协议时,各协议之间用逗号`,`分隔,如下所示: +要使类遵循某个协议,需要在类型名称后加上协议名称,中间以冒号`:`分隔,作为类型定义的一部分。遵循多个协议时,各协议之间用逗号`,`分隔: ```swift struct SomeStructure: FirstProtocol, AnotherProtocol { @@ -45,7 +45,7 @@ struct SomeStructure: FirstProtocol, AnotherProtocol { } ``` -如果一个类在含有`父类`的同时也采用了协议,应当把`父类`放在所有的`协议`之前,如下所示: +如果类在遵循协议的同时拥有父类,应该将父类名放在协议名之前,以逗号分隔: ```swift class SomeClass: SomeSuperClass, FirstProtocol, AnotherProtocol {