Tip: If you use your phone and tablet to see this article, please read it in the WiFi environment, there are many pictures, it will waste a lot of traffic.
Bo Master language has been bad (if there are any typos, please comment) hope you understand, have not learned anything
The most recent 2 days have been to upgrade systems and upgrade development tools and to chew on Apple's development documentation, as well as to write Swift articles. I also learn swift while doing some small examples to play. Personal feeling of grammar refining, it is still very cool to use.
But personally feel that the development tools still have a lot of shortcomings (such as automatic hints sometimes do not appear), I hope that Apple in the release of the official version can be repaired a little better, in the back I will write down the experience of my mistakes.
Today is the official swift language, starting with the "Hello World" program.
Personal development environment:
System
OS X Yosemite 10.10
Tools
Xcode 6.0 Bate
If you do not have a developer account to download Xcode 6.0 bate, please go to Swift's introductory article-swift introduction
---------------------------Formal Development------------------
First step: Find the Xcode 6.0 BATE application, and click on the Xcode 6.0 Bate app
The second step is to click on the "Create a New Xcode Project" program.
Step three: Select "Application" under OS x, then select "Command Line Tool" and click Next.
Fourth step: Fill in the "Project name" in "Product name" and select the "Swift" language in "Language". , click Next.
Fifth Step: Select Save Location, click Create
Sixth step: Double-click the Main.swift file, the following interface appears
/*----New This Hello World this project is for me to introduce you to one: Main.swift file is the entry of the program Example 1: // main.swift Explanation: Double slash (//) is the identification of a comment. Identify program readability Examples 2:import Foundation interpretation: Import is a keyword for swift, the role of the import header file foudation is the head file of Swift's framework. If you have a good understanding of ojbect-c should be very clear), if you have not learned object-c language is not related, you first understand, will be introduced in the following. Example 3:println ("Hello, world!") Explanation:p Rintln () is an output function (also called a print log) that outputs a string directly. */
Here's a look at the use of the println () function:
1: Direct Output string
main.swift// helloworld//import foundationprintln ("Swift")//Direct output string println ("My first Swift")//Direct output String
Note the point:
println ("SWIFT") is not followed by a colon and does not have an error.
println ("Swift") and println ("Swift");
The meaning of expression is the same.
But Apple recommends that developers use the println ("SWIFT") developer documentation to use the
Run results
2: The placeholder output placeholder for the notation \ () parentheses must put constants and variables (note that the constant in parentheses cannot be a string, only the basic types such as shaping floating-point types)
main.swift// helloworld//import foundationprintln ("Hello World \ (1)"),// \ () is a placeholder 1 is a constant
Run results
Wrong wording
main.swift// helloworld//import foundationprintln ("Hello World")//error notation \ () inside can only put the shape of floating-point type such as basic type, cannot put string
Today only to introduce here, the back of the article, I went back to learn from the Swift language of the knowledge to write to form a series. As a new language, personal understanding inevitably has shortcomings, welcome to give me advice. can also add my QQ 14,360,511,081 discussion, if you have any problem, you can also directly in QQ message sent to me, I saw the first time after you reply
Swift Introductory chapter-hello World