代码之家  ›  专栏  ›  技术社区  ›  Maarten Bodewes

cfstring.self是什么意思?

  •  1
  • Maarten Bodewes  · 技术社区  · 6 年前

    我看过问答 here about the self keyword in Swift .

    但是,对我来说这并不能解释 .self 在下面的代码片段中 this question

    let attributes: [String: Any] =
        [kSecAttrKeyType as String:CFString.self,
         kSecAttrKeySizeInBits as String:numberOfBits]
    

    什么? 自己 在这种情况下呢?

    1 回复  |  直到 6 年前
        1
  •  3
  •   matt    6 年前

    Type.self 是作为值的类型。

    两者之间有区别

    let s : String = "hello world"
    

    其中string声明 s

    let sometype : Any = String.self
    

    我们将字符串类型本身指定为 价值 储存起来。那叫做 元类型 .