http://blog.csdn.net/powerlly/article/details/29351103
Swift Development Learning: the initial Chapter
About
Apple is in WWDC2014 (Apple Worldwide Developers Conference. June 2-6, San Francisco) publishes the new programming language--swift. Here does not repeat the introduction, this chapter is a brief list of several points, and then introduce the swift operation.
What is Swift?
- Swift is the programming language used to write iOS and OS X programs.
- Swift absorbs the benefits of C and objective-c and is more powerful and easy to use.
- Swift can use the existing cocoa and cocoa touch frameworks.
- Swift combines the high performance (performance) and scripting language interactivity (Interactive) of the compiled language.
What are the features of Swift?
- property, nullable Value (Nullable type), generic (Generic type) syntax, derived from C #;
- Format style: At the end of the sentence can be no semicolon, judging conditions do not need parentheses, with go style;
- The current instance uses the self reference syntax, the list/dictionary declaration syntax, and the Python style;
- Interval declaration syntax (such as: 1..) 3: Front closed rear open [1,2],1...3: Front closed rear closed [+]], with Haskell style;
- Protocol (Protocol) and Extension (extension), originating from Objective-c;
- Enum (enum) types can have members or methods, much like Java;
- Classes (Class) and struct (struct) concepts, similar to C #.
What IDE is used to develop swift
- Xcode6 begins support for Swift language
- XCODE6 provides a playground interface that allows you to see the execution effect while developing
Please keep this link for the original power reprint.
Environment preparation
- MAC OS Version
Does not need to be updated to the newly released OS X v10.10 and is not currently stable
You can upgrade to OS X 10.9. Install Xcode6 Beta
- Xcode6 Beta Download [can thunder]
Xcode6 Beta Installation
There is no need to worry about coverage issues with other versions of Xcode installed
When you download the xcode_6_beta.dmg installation, it installs to the new directory.
Create a project
Start our new Swift journey after the installation is successful.
First, let's create a swift language project.
As with the original project, simply select Swift in the language selection
Swift ranked first in the language option, showing how much Apple attaches to it. Future estimates will be the default option.
After the project is created, you will find nothing different from the previous Hello World
What about the playground? You will find in the lower right corner there is such a file type playground
You know what you're doing?
Hello Swift
Second, add the playground file
- Drag directly from the lower right corner to the project
- file-"new-" File ..., select playground
Middle: Code Editing area
Left: Live effect, not output OH
Bottom right: Post-run results, Note: execution effect
With the playground, the teachers no longer have to let the students yy ~~~!
Question: How do I execute the code in playground? Please see the next introduction
Please keep this link for the original power reprint.
Changelist:
June 9
Quick Create with Playground project
Before the start of Xcode setup is not realistic welcome interface, so did not notice also can quickly create playground project
Ways to open the Xcode Welcome screen:
- Menu: Window, Welcome to Xcode
- Shortcut keys: Shift + Command + 1
?? Show This window when Xcode launches
You can open the Welcome screen at startup
Select "Get started with a playground" to create a project with playground directly.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Swift Development Learning (a): initial article