zoukankan      html  css  js  c++  java
  • IOS开发-Swift新语言初见

    Safe

    Swift pairs increased type safety with type inference, restricts direct access to pointers, and automatically manages memory—making it easy to create secure, stable software.

    • func configureLabels(labels: UILabel[]) {
    • let labelTextColor = UIColor.greenColor()
    • for label in labels {
    • // label inferred to be UILabel
    • label.textColor = labelTextColor
    • }
    • }

    Modern

    Swift includes optionals, generics, tuples, and other modern language features. Inspired by and improving upon Objective-C, Swift code feels natural to read and write.

    • let cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"]
    • let sortedCities = sort(cities) { $0 < $1 }
    • if let indexOfLondon = find(sortedCities, "London") {
    • println("London is city number (indexOfLondon + 1) in the list")
    • }

    Powerful

    Take advantage of powerful pattern matching in Swift to write simple, expressive code. Format strings naturally with string interpolation. Use frameworks like Foundation and UIKit directly from Swift.

    • let size = (20, 40)
    • switch size {
    • case let (width, height) where width == height:
    • println("square with sides (width)")
    • case (1..10, 1..10):
    • println("small rectangle")
    • case let (width, height):
    • println("rectangle with width (width) and height (height)")
    • }

    Interactive

    Use playgrounds to experiment with new technologies, analyze problems, and prototype user interfaces.

    image: ../Art/largeshot.pdf

    Fast

    The Swift compiler applies advanced code analysis to tune your code for performance, letting you focus on writing great apps instead of on implementing complex optimizations.

  • 相关阅读:
    软件测试总结
    接口测试总结与分享
    Android自动化测试框架
    Jmeter系列- Jmeter 分布式测试
    python+requests接口自动化测试实战
    测试十年的前辈工作心得与经验分享
    一次压测实战的复盘
    (纯技术干货)完整的框架搭建过程 实战 Python+unittest+requests 接口自动化测试
    Android自动化测试框架必用工具
    第八周作业
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4295428.html
Copyright © 2011-2022 走看看