The beginning iOS8 Programming with Swift 中文翻譯 - 7

來源:互聯網
上載者:User

標籤:

周末兩天沒有更新,今天繼續!

1  Build Your First App  建立你的第一個App

  “The way to get started is to quit talking and begin doing.”     開始就是放棄高談闊論,開始腳踏實地!

                        – Walt Disney                   - 沃爾特·迪斯尼(迪士尼創始人)

Hello World! Build Your First App Using Swift    你好,世界!用swift建立你的第一個App

By now you should have installed Xcode 6 and some understandings of Swift language. If you haven’t done so, check out the previous chapter about what you need to begin iOS programming. We’ll use Xcode 6.1 (or up) to work on all exercises in this book.

現在你應該已經安裝好了Xcode6並且對swift語言有了一定的瞭解.如果你還沒有做到,那麼請回顧之前的關於你需要做什麼才能開始iOS開發的章節.在這本書中,我們將使用Xcode6.1或以上版本來做所有的練習.

You may have heard of “Hello World” program if you have read any programming book before. Hello World is a program for first-time programmer to create. It’s a very simple program that outputs “Hello, World” on the screen of a device.

如果你之前有讀過一些關於開發的書籍,那麼你應該知道他們很多都是以"hello worod"來開篇的.Hello world是對於編程初學者來建立的一個程式,那是一個非常簡單的只是輸出一個"Hello world"在裝置的螢幕上.

It’s a tradition in the programming world. So, let’s follow the programming tradition and create a “Hello World” app using Xcode. Despite its simplicity, the “Hello World” program serves a few purposes:

在程式的世界裡這是一個傳統.所以,讓我們跟隨著程式的傳統,在xcode中建立一個"Hello world" app.儘管他是非常非常的簡單的基礎的,不過"Hello World"也要為這幾個目的而存在.

 

    • It gives you an overview about the syntax and structure of Swift, the new programming language of iOS.      他會讓你對swfit的文法和結構有一個大致的瞭解,一個iOS的新程式設計語言.

    • It also gives you a basic introduction to the Xcode 6       他同樣可以讓你對Xcode6環境有一個入門.(基礎的介紹)
      environment. You’ll learn how to create a Xcode project and   你將學到如何去建立一個Xcode項目
      lay out your user interface using Storyboard. Even if you’ve    如何使用storyboard定製你的使用者介面.
      used Xcode 5 before, you’ll learn what’s new in the latest version of Xcode.  即使你之前使用過Xcode5,你也可以學習到最新版本的Xcode有哪些更新.

    • You’ll learn how to compile a program, build the app and test it using the Simulator.    你將學習到如何編譯一個程式,建立一個app以及 如何使用模擬器進行測試.

    • Lastly, it makes you think programming is not difficult. I don’t want to scare you away   最後,它會讓你意識到編程不是那麼的困難.我不想把你從學習編程的路上給嚇跑.

      from learning programming. It’ll be fun.  他是充滿樂趣的.

 

Your First App  你的第一個APP                                                                                                                                                                                                   Your first app, as displayed in figure 1-1, is very simple and just shows a “Hello World” button. When user taps the button, the app shows a welcome message. That’s it. Extremely simple but it helps you kick off your iOS programming journey. 

你的第一個app,就像用數字表現1-1一樣,是非常簡單的,只是展示一個“hello world”按鈕。當使用者點擊這個按鈕,app將顯示歡迎資訊,僅僅如此。極其簡單,但是它將協助你開啟你的iOS編程之旅。

It’s normal if you do not understand the source code. Just relax and focus on building your first app. Familiarize yourself with the Xcode environment and Storyboard. I will explain the language as we go along and you will learn how the HelloWorld app works in the next chapter. 

如果你不理解代碼的原理是非常正常的。你只需要放輕鬆,把注意力放在建立你的第一個app上。去讓自己熟悉Xcode環境和storyboard,我將在我們進行的過程中解釋這個語言並且在下一章節你會學習怎麼使hello world運行。

 

Let‘s Jump Right Into Create a Project   讓我們轉去建立一個項目吧

First, launch Xcode. If you’ve installed Xcode via Mac App Store, you should be able to locate Xcode in the LaunchPad. Just click on the Xcode icon to start it up.

Once launched, Xcode displays a welcome dialog. From here, choose “Create a new Xcode project” to start a new project: 

第一步,運行Xcode.如果你之前已經在Mac蘋果商店安裝過Xcode,你應該可以在LaunchPad裡找到Xcode,你只需要點擊Xcode表徵圖即可啟動它。

第一個運行,Xcode將展現一個歡迎介面。從這裡,選擇“Create a new Xcode project”開始程式:

 

Xcode shows various project template for selection. For your first app, choose “Single View Application” and click “Next”. 

Xcode顯示了各種各樣的項目模板供你選擇,對於你的第一個app,選擇“Single View Application” 並且點擊“Next”

This brings you to the next screen to fill in all the necessary options for your project. 

這將跳轉到一個你的項目中必須設定的介面。

You can simply fill in the options as follows:   你可以遵循下面的介紹來簡單的填寫設定
Product Name: HelloWorld – This is the name of your app.Organization Name: AppCoda – It’s the name of your organization.  

項目名稱:HelloWorld-這是你的APP的名字    組織名稱:AppCoda-這是你公司(組織)的名字

Organization Identifier: com.appcoda – It’s actually the domain name written the otherway round. If you have a domain, you can use your own domain name. Otherwise, youmay use “com.appcoda” or just fill in “edu.self”.

組織的標示符:com.appcoda-這實際上是你的組織的網域名稱反過來寫。如果你有一個網域名稱,你可以使用你的網域名稱名字,如果沒有,你可以寫com.appcoda來填寫

 

Bundle Identifier: com.appcoda.HelloWorld - It’s a unique identifier of your app which isused during app submission. You do not need to fill in this option. Xcode automaticallygenerates it for you.

捆綁的標示符:com.appcoda.HelloWorld-這是在你的app提交的時候使用的獨一無二的標示符。你不用自己手動填寫。Xcode會問你自動產生。

 

Language: Swift – Xcode 6 supports both Objective-C and Swift for app development. Asthis book is about Swift, we’ll use Swift to develop the project. 

語言:swift : swfit-Xcode6支援Objective-C和swift對app進行開發.這本書是關於swift,我們將使用swift來開發項目.

Devices: iPhone – Select “iPhone” for this project. 

裝置:iPhone- 這個項目選擇"iPhone"

Use Core Data: [unchecked] – Do not select this option. You do not need Core Data for this simple project. We’ll explain Core Data in later chapters.

使用Core Data: 不要選擇這個選項.這個簡單的項目是不需要使用Core Data的.我們將在以後的章節解釋他.

Click “Next” to continue. Xcode then asks you where to save the “HelloWorld” project. Pick any folder (e.g. Desktop) on your
Mac. You may notice there is an option for source control. Just deselect it. We do not need to use the option in this book. Click “Create” to continue.

點擊"Next"繼續.Xcode會詢問你在哪裡儲存"Hello World"項目.選擇你Mac電腦任意的一個位置去儲存.你或許對於版本控制會有一些疑問,你只需不選擇他啊,我們在這本書都不會使用到這個選項,點擊"Create"繼續.

As you confirm, Xcode automatically creates the “Hello World” project. The screen willlook like the screenshot shown in figure 1-6. You can ignore the “No matching signingidentity found” error. 

得到你的確認後,Xcode自動的建立了"Hello world"項目,在螢幕中可能會看到像的螢幕.你可以忽略"No matching signing indentity found"錯誤.

 

The beginning iOS8 Programming with Swift 中文翻譯 - 7

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.