user3153627
user3153627

Reputation: 1385

How to create Dictionary inside Array structure in Swift?

I want to create something like this in Swift

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

I surfed around and also referred https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_399
but no luck. Can anyone please help?
Thanks in advance.

Upvotes: 1

Views: 3809

Answers (1)

Bogdan
Bogdan

Reputation: 1286

Easy as can be

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

PlayGround snap :PlayGround snap

Upvotes: 8

Related Questions