New document that describes Swift 1.0, Apple’s new programming language for building iOS and OS X apps.
Added a new section about Initializer Requirements in protocols.
Added a new section about Class-Only Protocols.
Assertions and Preconditions can now use string interpolation. Removed a note to the contrary.
Updated the Concatenating Strings and Characters section to reflect the fact that
Character values can no longer be combined with the addition operator (
+) or addition assignment operator (
+=). These operators are now used only with
String values. Use the
append(_:) method to append a single
Character value onto the end of a string.
Added information about the
availability attribute to the Declaration Attributes section.
Optionals no longer implicitly evaluate to
true when they have a value and
false when they do not, to avoid confusion when working with optional
Bool values. Instead, make an explicit check against
nil with the
!= operators to find out if an optional contains a value.
Swift now has a Nil-Coalescing Operator (
a ?? b), which unwraps an optional’s value if it exists, or returns a default value if the optional is
Updated and expanded the Comparing Strings section to reflect and demonstrate that string and character comparison and prefix / suffix comparison are now based on Unicode canonical equivalence of extended grapheme clusters.
You can now try to set a property’s value, assign to a subscript, or call a mutating method or operator through Optional Chaining. The information about Accessing Properties Through Optional Chaining has been updated accordingly, and the examples of checking for method call success in Calling Methods Through Optional Chaining have been expanded to show how to check for property setting success.
Added a new section about Accessing Subscripts of Optional Type through optional chaining.
Updated the Accessing and Modifying an Array section to note that you can no longer append a single item to an array with the
+= operator. Instead, use the
append(_:) method, or append a single-item array with the
Added a note that the start value
a for the Range Operators
a..<b must not be greater than the end value
Rewrote the Inheritance chapter to remove its introductory coverage of initializer overrides. This chapter now focuses more on the addition of new functionality in a subclass, and the modification of existing functionality with overrides. The chapter’s example of Overriding Property Getters and Setters has been rewritten to show how to override a
description property. (The examples of modifying an inherited property’s default value in a subclass initializer have been moved to the Initialization chapter.)
Updated the Initializer Inheritance and Overriding section to note that overrides of a designated initializer must now be marked with the
Updated the Required Initializers section to note that the
required modifier is now written before every subclass implementation of a required initializer, and that the requirements for required initializers can now be satisfied by automatically inherited initializers.
Infix Operator Methods no longer require the
@postfix attributes for Prefix and Postfix Operators have been replaced by
postfix declaration modifiers.
Added a note about the order in which Prefix and Postfix Operators are applied when both a prefix and a postfix operator are applied to the same operand.
Operator functions for Compound Assignment Operators no longer use the
@assignment attribute when defining the function.
The order in which modifiers are specified when defining Custom Operators has changed. You now write
prefix operator rather than
operator prefix, for example.
Added information about the
dynamic declaration modifier in Declaration Modifiers.
Added information about how type inference works with Literals.
Added more information about curried functions.
Added a new chapter about Access Control.
Updated the Strings and Characters chapter to reflect the fact that Swift’s
Character type now represents a single Unicode extended grapheme cluster. Includes a new section on Extended Grapheme Clusters and more information about Unicode Scalars and Comparing Strings.
Updated the String Literals section to note that Unicode scalars inside string literals are now written as
n is a hexadecimal number between 0 and 10FFFF, the range of Unicode’s codespace.
length property is now mapped onto Swift’s native
String type as
String type no longer has an
lowercaseString property. The corresponding section in Strings and Characters has been removed, and various code examples have been updated.
Added a new section about Initializer Parameters Without Argument Labels.
Added a new section about Required Initializers.
Added a new section about Optional Tuple Return Types.
Updated the Type Annotations section to note that multiple related variables can be defined on a single line with one type annotation.
@required attributes are now the
required Declaration Modifiers.
Updated the entire book to refer to
..< as the Half-Open Range Operator (rather than the “half-closed range operator”).
Updated the Accessing and Modifying a Dictionary section to note that
Dictionary now has a Boolean
Clarified the full list of characters that can be used when defining Custom Operators.
nil and the Booleans
false are now Literals.
Array type now has full value semantics. Updated the information about Mutability of Collections and Arrays to reflect the new approach. Also clarified the Assignment and Copy Behavior for Strings, Arrays, and Dictionaries.
Array Type Shorthand Syntax is now written as
[SomeType] rather than
Added a new section about Dictionary Type Shorthand Syntax, which is written as
Added a new section about Hash Values for Set Types.
Examples of Closure Expressions now use the global
sorted(_:_:) function rather than the global
sort(_:_:) function, to reflect the new array value semantics.
Updated the information about Memberwise Initializers for Structure Types to clarify that the memberwise structure initializer is made available even if a structure’s stored properties do not have default values.
..< rather than
.. for the Half-Open Range Operator.
Added an example of Extending a Generic Type.