Swift 2.0 Introduction

WWDC conference in June this year on, Apple released Swift 2.0 Programming language。This new version has improved performance,The new API error control and detection support class availability。And improved Apple SDK platform API to make it more native to Swift。


For new features for,Also worth noting is that Apple will open later this year Swift 。Over time,Apple will release more news about open source,At present the following information:

  • Swift will be in source code OSI approvedofPermit issued.
  • Community contribution accepting - encouraging community contribution.
  • mainly OS X, iOS, And Linux.
  • Swift include source code compiler and standard library.

New features

Swift 2.0 Also it includes many new language features and minor improvements。The main new features are as follows:

Error processing module:

Swift 2.0 The new error-handling module will make you feel naturally smoothly,With familiar try, throw, and catch Keyword。It is important,It is specifically designed for Apple SDKs and Designed NSError。Actually,NSError Swift followed the wrong type。


Using the latest SDK to make sure you get all the new features and modify the information platform。But sometimes you still need to do development for older versions of the OS,Swift allows you to use a simpler and safer way to carry out。Swift compiler can now display incompatible API error when you developed for older versions of OS, The same time #available Block code can be safely packaged in the correct version of OS。

Protocol Extensions:

Swift focused on development-oriented agreement - there is even a special topic for discussion at the 2015 WWDC conference this。Swift 2.0 Add a protocol extension,And standard library itself is common to use them。Where you have been accustomed to using global functions,Swift 2.0 To add them as a method of the type commonly used among,The chain function more naturally,Code is also easier to read。

Swift 化 SDK:

Swift 2 And Apple More compatible SDK, It should rely on two new features of Objective-C: Empty annotations and generics。SDK has been upgraded to comment API can not return nil,You no longer need to frequent use of the option。Also the presence of the generic system since the true SDK,You can maintain more frequent Swift 2 Details Type code。

understand more

It's just Swift 2 Brief new features。You can download the latest version from the iBook Store The Swift Programming Language ,At the same time to wait to see the video of this WWDC,Or venue http://developer.apple.com/swift View more detailed information。

Original article written by Gerber drop-off:R0uter's Blog » Swift 2.0 Introduction

Reproduced Please keep the source and description link:https://www.logcg.com/archives/1041.html

About the Author


The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *