zoukankan      html  css  js  c++  java
  • swift语言点评二

    一、数据类型

    1、基础类型的封装

    Swift provides its own versions of all fundamental C and Objective-C types, including Int for integers, Doubleand Float for floating-point values

    2、新类型

     Swift introduces advanced types not found in Objective-C, such as tuples.

    Tuples enable you to create and pass around groupings of values.

    3、类型安全语言

    Swift is a type-safe language, which means the language helps you to be clear about the types of values your code can work with.

    4、数据类型转化

    1. let three = 3
    2. let pointOneFourOneFiveNine = 0.14159
    3. let pi = Double(three) + pointOneFourOneFiveNine
    4. // pi equals 3.14159, and is inferred to be of type Double

    5、Tuples

    1. let http404Error = (404, "Not Found")
    1. let (statusCode, statusMessage) = http404Error
    2. print("The status code is (statusCode)")
    3. // Prints "The status code is 404"
    4. print("The status message is (statusMessage)")
    5. // Prints "The status message is Not Found"

    6、Optionals

    1. let possibleNumber = "123"
    2. let convertedNumber = Int(possibleNumber)

      类型推断 convertedNumber:Int?

    7、Optional Binding

      if let firstNumber = Int("4")

      You use optional binding to find out whether an optional contains a value

    8、Implicitly Unwrapped Optionals

     . You write an implicitly unwrapped optional by placing an exclamation mark (String!) rather than a question mark (String?) after the type that you want to make optional.

  • 相关阅读:
    Kali,CentOS 配置静态网络与开启SSH服务【附VMware中配置】
    httpHelper请求辅助类
    请求后的数据处理
    Viewcontroller基类
    上拉下拉基类
    获取cell中的button在整个屏幕上的位置
    Object-C反射读取实体属性和值
    xcode在代码中查找中文
    编写xcode5插件需要增加DVTPlugInCompatibilityUUIDs
    c# 扩展方法
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8677949.html
Copyright © 2011-2022 走看看