File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 3
3
Define types inside the scope of another type.
4
4
5
5
Enumerations are often created to support a specific class or structure's functionality.
6
- Similarly, it can be convenient to define utility classes and structures
7
- purely for use within the context of a more complex type.
6
+ Similarly, it can be convenient to define utility structures
7
+ purely for use within the context of a more complex type,
8
+ and protocols that are normally used in conjunction with a specific type.
8
9
To accomplish this, Swift enables you to define * nested types* ,
9
- whereby you nest supporting enumerations, classes , and structures
10
+ whereby you nest supporting types like enumerations, structures , and protocols
10
11
within the definition of the type they support.
11
12
12
13
To nest a type within another type,
Original file line number Diff line number Diff line change @@ -858,13 +858,14 @@ The `DiceGame` protocol is a protocol that can be adopted
858
858
by any game that involves dice.
859
859
860
860
The ` DiceGame.Delegate ` protocol can be adopted
861
- to track the progress of a ` DiceGame ` .
861
+ to track the progress of a type that implements ` DiceGame ` .
862
862
Because the ` DiceGame.Delegate ` protocol
863
863
is always used in the context of a dice game,
864
864
it's nested inside of the ` DiceGame ` protocol.
865
865
Protocols can be nested inside of other protocols
866
866
and inside of type declarations like structures and classes,
867
867
as long as the outer declaration isn't generic.
868
+ For information about nesting types, see < doc:NestedTypes > .
868
869
869
870
To prevent strong reference cycles,
870
871
delegates are declared as weak references.
You can’t perform that action at this time.
0 commit comments