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

Study app programming question.

I wanted to create an app that simply loads a question and then when a button is pushed it loads a corresponding answer.

What would be the best way to store the question and answers to support "MVC" principals?

Put questions and answers in a PList?

Put questions and answers in a NSDictionary?

Thanks.

3 Answers

Hey Chris,

Sorry for the late reply!

I did this to access the Plist.

var plistPath = NSBundle.mainBundle().pathForResource("arrayOfStrings", ofType: "plist")
var array = NSArray(contentsOfFile: plistPath)

You can let use the array variable as though it were a normal array you just created. If you had a dictionary in your plist you would just need to change the array variable to be of type NSDictionary.

I recently created an app which used did the same sort of thing except it wasn't with questions and answers.

In my case I used a plist because I felt the data was 'tider'... I guess as long as the data isn't in your ViewController then it sticks to the mvc design pattern.

Stephen,

What code or method did you use to access the Plist so that it could be displayed?