1

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.

0

1 Answer 1

8

Easy as can be

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

PlayGround snap :PlayGround snap

Sign up to request clarification or add additional context in comments.

3 Comments

That was actually simple! Thanks a ton @eXhausted. Can you tell me what are the substitutes for objectAtIndex and valueForKey?
let array = [["IDE": "Xcode", "language": "iOS"], ["IDE": "Eclipse", "language": "Java"]] let object = array[0] println(object["IDE"]) try this code to figure out
In case someone else is looking for creating multiple object/keys with NSDictionary: var eventDict = NSDictionary(objectsAndKeys: "value1", "key1", "value2", "key2")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.