Multiple improvements
The new Apple programming language Swift is a big update, and developers can use Swift to write better, more secure applications. The new Swift programming language fixes many requests made by developers. In addition, Apple has updated the ibooks book, which introduces Swift, to reflect the new changes.
Update Time: 2014-07-07
Update content:
- Swift's type now have full
Array
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.
- The array type becomes a numeric type, implemented by a struct, so that when assigned or passed as a parameter, a completely new value is copied, rather than a class, just a reference is passed.
- The assignment and replication of array and dictionary in the corresponding Nineth class and structure are also updated, and the translation is launched as soon as possible.
- Array Type Shorthand Syntax is now written as
[SomeType]
rather than SomeType[]
.
- The writing form of an array is changed from sometype[] to [SomeType]
- var shoppinglist: [String] = ["Eggs", "Milk"]
- Added a new section on Dictionary Type shorthand Syntax, which is written as
[KeyType: ValueType]
.
- Abbreviated form of dictionary type: [string:string]
- var airports: [String:string] = ["Tyo": "Tokyo", "DUB": "Dublin"]
- Added a new section on Hash Values for Dictionary Key Types.
- As the type of the key in the dictionary type, it must be a hash
- Both the string,int,double and bool types are hashed, so they can be used as keys to the dictionary
- Examples of Closure Expressions now
sorted
with the global function rather than the global sort
function, to reflect the new Array value semantics.
- The closure expression uses the global sorted function to represent the new array semantics
- Updated the information about memberwise initializers for Structure Types to clarify that the memberwise Structure initial Izer is made available even if a structure ' s stored properties does not have default values.
- struct-type member-by-construct method default exists
- Can be used directly regardless of whether the structure's properties have an initial value
- Updated to
..<
rather than for the ..
half-closed Range Operator.
- Left closed right open interval representation, using: < Replace the original.
- 1.. < 5 means 1,2,3,4. 1 ... 5 = 1,2,3,4,5
- This writing method is easier to understand and use
- Added An example of extending a Generic Type.
- A new example was added in the extension
iOS Development--swift & Classic Syntax 26) syntax correction