• Swift1


    Swift是一门为Cocoa和Cocoa Touch服务的创新设计的语言。写代码是交互和有趣的,语法简介并富有表现力,应用运行轻快。Swift是为下个iOS 和OS X项目,或者说是你当前应用——因为Swift代码和OC语言是并行的。

    Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C.

    Swift Screenshot

    现代Modern

    Swift是最新的对编程语言研究的结果,结合了近几十年的苹果平台经验。命名的参数是从OC中提出的,表达一个清晰的愈发,使Swift 的帮助文档更容易阅读和维护。

    Swift is the result of the latest research on programming languages, combined with decades of experience building Apple platforms. Named parameters brought forward from Objective-C are expressed in a clean syntax that makes APIs in Swift even easier to read and maintain.

    
    var sortedStrings = sorted(stringArray) {
    	$0.uppercaseString < $1.uppercaseString
    }
    				

    推断类型让代码更清晰并且不容易出错,模块消除了头部改为提供命名空间。内存管理自动的,甚至不需要输入分号。

    Inferred types make code cleaner and less prone to mistakes, while modules eliminate headers and provide namespaces. Memory is managed automatically, and you don’t even need to type semi-colons.

    Swift 有许多其他特性来使你的代码更富有表现力Swift has many other features to make your code more expressive:

    • 封闭一元化的函数指针Closures unified with function pointers
    • 元组和多种返回值Tuples and multiple return values
    • 泛化Generics
    • 在一个范围或集合中快速和简洁的迭代Fast and concise iteration over a range or collection
    • 结构体支持方法、扩展、协议Structs that support methods, extensions, protocols.
    • 函数式的编程模式,如地图、过滤器Functional programming patterns, e.g.: map and filter

    互动游乐场Interactive Playgrounds

    Playgrounds

    游乐场让Swift 代码编写更简洁有趣。键入一行代码,立刻可以出现结果。如果你的代码运行中,例如正在通过一个循环,可以在timeline助理中看到它的进展。timeline在一个图表中展示变量,当构建一个视图时绘制每一步,可以动态播放SpriteKit场景。当你在游乐场完善代码后,很简单就可以将代码移动到项目中。一些游乐场的使用包括:

    Playgrounds make writing Swift code incredibly simple and fun. Type a line of code and the result appears immediately. If your code runs over time, for instance through a loop, you can watch its progress in the timeline assistant. The timeline displays variables in a graph, draws each step when composing a view, and can play an animated SpriteKit scene. When you’ve perfected your code in the playground, simply move that code into your project. Some uses for playgrounds include:

    • 设计一个新的算法,观察它的结果的每一步的方式Design a new algorithm, watching its results every step of the way
    • 创建新的测试,在提交到单元测试之前验证它们的运行Create new tests, verifying they work before promoting into your test suite
    • 新的帮助文档的实验,来磨练Swift 编码技能Experiment with new APIs to hone your Swift coding skills

    读取-求值-打印-循环Read-Eval-Print-Loop (REPL). 调试控制台在Xcode中包括一个Swift 语言正确创建的交互式版本。使用Swift 语法来评估和交互正在运行的应用,或者写一段新代码在一个类似脚本的环境中看它如何运行。通过Xcode控制台或者终端是可行的。

    The debugging console in Xcode includes an interactive version of the Swift language built right in. Use Swift syntax to evaluate and interact with your running app, or write new code to see how it works in a script-like environment. Available from within the Xcode console, or in Terminal.

    安全设计Designed for Safety

    Swift 淘汰了所有类中不安全的代码。变量在使用前被就被初始化,数组和整数有溢出检查,内存管理是自动的。语法变得让你意图的定义更容易,例如,三个字符的关键字定义一个变量或者常量。

    Swift eliminates entire classes of unsafe code. Variables are always initialized before use, arrays and integers are checked for overflow, and memory is managed automatically. Syntax is tuned to make it easy to define your intent — for example, simple three-character keywords define a variable (var) or constant (let).

    安全模型被调整以适应强大的Cocoa 和Cocoa Touch 帮助文档。理解和适当的处理对象为空的情况,是对此框架基本的要求,Swift 代码使得这个功能极其简单就完成。只是添加一个字符可以替换原先OC要一行代码实现的东西。这些所有的一起工作使得创建iOS 和Mac 应用更简单和安全。

    The safe patterns in Swift are tuned for the powerful Cocoa and Cocoa Touch APIs. Understanding and properly handling cases where objects are nil is fundamental to the frameworks, and Swift code makes this extremely easy. Adding a single character can replace what used to be an entire line of code in Objective-C. This all works together to make building iOS and Mac apps easier and safer than ever before.

    快速和有效的Fast and Powerful

    从最早期的概念,Swift 被创建使得编码更快速。使用难以置信的高效LLVM编译器,Swift 代码被转化为优化的本机代码,调协获得更大的现代Mac 和iPhone、iPad 设备。语法和标准库也已经调协让最明显的方式来写代码,也执行最好。

    From its earliest conception, Swift was built to be fast. Using the incredibly high-performance LLVM compiler, Swift code is transformed into optimized native code, tuned to get the most out of modern Mac, iPhone, and iPad hardware. The syntax and standard library have also been tuned to make the most obvious way to write your code also perform the best.

    Swift 是一个C和OC的继承。它包含底层原语如类型、流量控制、运营商。还提供了面向对象的特征如类、协议、泛化,给Cocoa 和Cocoa Touch 开发者提供需要的性能和功率要求。

    Swift is a successor to the C and Objective-C languages. It includes low-level primitives such as types, flow control, and operators. It also provides object-oriented features such as classes, protocols, and generics, giving Cocoa and Cocoa Touch developers the performance and power they demand.

    开发准备Ready Today

    Xcode

    可以即可使用Swift 代码完成应用中的新功能,或者强化现有的功能。新Swift 代码可以和你的已有的OC代码共存在同一个项目中,使得Swift 更容易适应。而且当iOS8和OS X Yosemite(今年8月发布)中,可以提交应用到App Store 和Mac App Store 中。

    You can begin using Swift code immediately to implement new features in your app, or enhance existing ones. New Swift code co-exists along side your existing Objective-C files in the same project, making it easy to adopt. And when iOS 8 and OS X Yosemite are released this fall, you can submit your apps to the App Store and Mac App Store.

    开始Swift开发,下载Xcode6,根据资源选项卡的可用教程。

    To get started with Swift, download Xcode 6 and follow the tutorials available on the Resources tab.

    寻找Swift 并行脚本语言?访问http://swift-lang.orgLooking for the Swift parallel scripting language? Please visit http://swift-lang.org

    iOS Android Appcan WeChat
  • 相关阅读:
    全面理解面向对象的 JavaScript
    账号
    移动端 前端框架 amaze ui
    javascript 精典案例分析一览
    前端事件系统(一)
    周总结12
    周总结11
    相比较于其他的同类软件
    团队冲刺第十五天
    团队冲刺第十四天
  • 原文地址:https://www.cnblogs.com/zyingn/p/Swift.html
Copyright © 2020-2023  润新知