Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Extra Credit question: Arrays/Dictionaries as arguments.

In one of the extra credit exercises, we were asked to pass in a dictionary into a func and return a tuple and I can't seem to figure out how to code it without passing every part of the dictionary individual (which is obviously not the intent). How do we pass arrays/dictionaries as arguments?

2 Answers

I had the same question. You'll find the answer here https://teamtreehouse.com/forum/swift-parameters-and-tuples-extra-credit-solution

Try these:

//To pass an Array
-(void) myMethodName:(NSArray *) yourArray{


}
//To pass a Dictionary
-(void) myMethodName:(NSDictionary *) yourDict{


}
//To pass both
-(void) myMethodName:(NSArray *) yourArray andMyDictionary:(NSDictionary*) yourDictionary{


}

That'd be fine in Cocoa, but I was asking in regards to Swift; sorry if I wasn't clear enough.