如何在Swift中的Array结构中创建Dictionary?

时间:2014-06-05 10:38:57

标签: ios swift

我想在Swift中创建类似的东西

NSArray *array = 
    [[NSArray alloc] initWithObjects:
        [NSDictionary dictionaryWithObjectsAndKeys:@"Xcode",@"IDE",@"iOS",@"language", nil],
        [NSDictionary dictionaryWithObjectsAndKeys:@"Eclipse",@"IDE",@"Java",@"language", nil]
    ,nil];

我四处浏览并提到了https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_399 但没有运气。有人可以帮忙吗? 提前谢谢。

1 个答案:

答案 0 :(得分:8)

很容易

let array = [["IDE": "Xcode", "language": "iOS"], ["IDE": "Eclipse", "language": "Java"]]

PlayGround snap: PlayGround snap