Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


get value from Dictionnary in a tableView with an indexPath.row?

I'm trying to get info from a plist. Here's the struct :


And a little sample of it :

<plist version="1.0">

So basically I'm to get the string value from a dictionary nested in another dictionary.

The trick is, I want to use a tableView

So far I'm here :

let pathRoot = NSBundle.mainBundle().pathForResource("MyPLIST", ofType: "plist")

let rootRubrique = NSDictionary(contentsOfFile: pathRoot!)

I'm trying to get the info like that :

let rubriqueTitre = NSDictionary(contentsOfFile: pathRoot!)?.allKeys[indexPath.row].objectForKey("gfx")?.valueForKey("titre")

But maybe the problem is from the way I'm trying to screen that

label.text = imageRubrique! as! String
// And also tried :
label.text = "\(imageRubrique!)"

Also I tried to get other values, just to try. This is working for me :

let rubriqueIndex = NSDictionary(contentsOfFile: pathRoot!)?.allKeys[indexPath.row]
 label.text = rubriqueIndex as! String

I get the "introduction" with a lower case, the first one. But I don't want that value, I want the nested one ! I'm getting crazy!

After that, I'll have to find a way to sort my dictionary in the right order which seems to be another big problem…