NSDictionaryOfVariableBindings swift equivalent?

前端 未结 7 1924
闹比i
闹比i 2020-12-08 01:47

The Apple documentation shows an unsettling blank space under the \'Creating a Dictionary\' section of the UIKit reference here.

Has anyone found a replacement for

7条回答
  •  旧时难觅i
    2020-12-08 02:12

    According to Apple source code:

    NSDictionaryOfVariableBindings(v1, v2, v3) is equivalent to [NSDictionary dictionaryWithObjectsAndKeys:v1, @"v1", v2, @"v2", v3, @"v3", nil];

    So in Swift you can do the same using:

    let bindings = ["v1": v1, "v2": v2, "v3": v3]
    

提交回复
热议问题