This tutorial is a summary of the iOS /Swift knowledge for programmers who use Objictive C programming and need to understand iOS-based iPhone and iPad applications. Do a bigger siege lion, work with dignity, work with joy, enjoy your work.

This article includes: Swift knowledge introduction

About the Swift,

Apple unveiled its new programming language, Swift, at WWDC2014(Apple Worldwide Developers Conference. June 2-6, San Francisco). For software users, for gamers, there’s a lot of talk about user experience. In fact, software developers are also users themselves, users of various development tools, and will like tools that do a good job of user experience. This time, Apple has offered developers a Playground to play Swift, which is convenient and fun for developers. This article mainly lists a few points briefly, and then introduces the operation of Swift entry.

What is Swift,

  • Swift is the programming language used to write iOS and OS X programs.
  • Swift takes the best of both C and Objective-C and is much more powerful and easy to use.
  • Swift can use existing Cocoa and Cocoa Touch frameworks.
  • Swift combines the Performance of a compiled language with the Interactive nature of a scripting language.

What are the features of SWIFT

  • Property, Nullable Type, Generic Type syntax, from C#.
  • Formatting style: There can be no semicolon at the end of the sentence, no need to judge the condition parentheses, same as GO style.
  • The current instance uses the self reference syntax and the list/dictionary declaration syntax, the same Python style.
  • Interval declaration syntax (e.g. 1.. 3: Front closed and back open [1, 2], 1… 3: front closed back closed [1,2,3]), same as Haskell style.
  • Protocol and extension, derived from Objective-C.
  • Enumeration (enum) types can have members or methods, much like Java.
  • The concept of classes and structs is similar to C#.

What IDE is used to develop Swift

  • Xcode6 began to support the Swift language.
  • Xcode6 provides the Playground interface where you can see the execution as you develop.

What can SWIFT do

1. Practice Swift quickly

No need to compile, no need to click to execute, just write code and see what it looks like. It’s much easier than scripting languages. Developers can use PlayGroud to quickly experiment with syntax, API calls, and more.

2. Visualize program logic

Playground not only provides an instant view of static variables, but it also shows values that change over time.

As shown in the figure, you can switch between the two editing attempts of the Playground by using the two buttons in the upper right corner:

  • Standard Editor displays variable values instantly.
  • The Assistant Editor displays variable values on the timeline, or customizes the display.

The Assistant mode will be important for developers to verify application logic:

  • Stepwise breakpoint debugging is no longer required.
  • Output log checking is no longer required.
  • Not only can display numerical curves, but also graphics and images.

3. Custom display

Developers can extend the dynamic display interface as needed to present the program in their own way. As demonstrated in WWDC2014:

What are the drawbacks of Playground

1.Playground temporarily does not support interface interaction. You can’t play the games you developed on our Playground. 2.Playground is not an emulator and cannot execute apps.

Environment to prepare

  • Mac OS version

Mac system version >= 10.9.3, my development environment is MacOS 10.10.1

  • Xcode6

Xcode version >= 6.0, my development environment is Xcode 6.1.1

A. | | create project

Let’s start our new Swift tour after the installation is successful. First, let’s create a Swift language project. As with the original creation project, you simply need to select Swift during the language selection.

The fact that Swift is the first language option shows how important Apple is that it will become the default one day.

Once the project is created, you’ll find that it’s the same as before.

What about Playground?

You’ll notice in the bottom right corner here is a file type Playground, see what we’re going to do?

Second, add the Playground file.

  1. Drag directly from the bottom right corner into the project
  2. File- “New-” File… , select the Playground

Middle: Code editing area.

Right: Real-time effect, not output.

Bottom right: the result after running, note: is the execution effect.

Quickly view variables, no compilation required

Once you’ve written the code in the code area, you can quickly see the results on playground. In the results shown on playground, there are two buttons at the end of each result, one is

A Quick Look at the results.

Value History: View History.

Quickly create projects with playground

How to open the Xcode welcome screen:

From the menu: window-> Welcome to Xcode-> select “Get Started with a playground” to directly create a project with playground.

Recommended at the end of the article: iOS popular collection & video analysis

1) Swift

② The underlying technology of iOS

③iOS reverse protection

④iOS interview collection

⑤ big factory interview questions + underlying technology + reverse security + SWIFT